zeiv/caseadilla

View on GitHub
app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js

Summary

Maintainability
F
4 days
Test Coverage

File jquery.wymeditor.table.js has 504 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global rangy */
"use strict";

// Fugue icons by Yusuke Kamiyamane http://p.yusukekamiyamane.com/
// and licensed under Creative Commons Attribution

    Function mergeRow has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    TableEditor.prototype.mergeRow = function () {
        var tableEditor = this,
            wym = tableEditor._wym,
            // Get all of the affected nodes in the range
            nodes = wym._getSelectedNodes(),

      Function TableEditor has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function TableEditor(options, wym) {
          var tableEditor = this;
          options = jQuery.extend({
              sMergeRowButtonHtml: String() +
                  '<li class="wym_tools_merge_row">' +

        Function getCellXIndex has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        TableEditor.prototype.getCellXIndex = function (cell) {
            var tableEditor = this,
                i,
                parentTr,
                baseRowColumns,

          Function bindEvents has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          TableEditor.prototype.bindEvents = function () {
              var tableEditor = this,
                  wym = tableEditor._wym;
          
              // Handle tool button click

            Function getTotalColumns has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            TableEditor.prototype.getTotalColumns = function (cells) {
                var tableEditor = this,
                    rootTr = tableEditor.getCommonParentTr(cells),
                    baseRowColumns,
                    colspanCount,

              Function removeColumn has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              TableEditor.prototype.removeColumn = function (elmnt) {
                  var tableEditor = this,
                      wym = tableEditor._wym,
                      td = wym.findUp(elmnt, ['td', 'th']),
                      table,

                Function getCellXIndex has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                TableEditor.prototype.getCellXIndex = function (cell) {
                    var tableEditor = this,
                        i,
                        parentTr,
                        baseRowColumns,

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function getTotalColumns has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                TableEditor.prototype.getTotalColumns = function (cells) {
                    var tableEditor = this,
                        rootTr = tableEditor.getCommonParentTr(cells),
                        baseRowColumns,
                        colspanCount,

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                TableEditor.GET_COLSPAN_PROP = function (cell) {
                    var colspan = jQuery(cell).attr('colspan');
                    if (typeof colspan === 'undefined') {
                        colspan = 1;
                    }
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 225..231

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 68.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                TableEditor.GET_ROWSPAN_PROP = function (cell) {
                    var rowspan = jQuery(cell).attr('rowspan');
                    if (typeof rowspan === 'undefined') {
                        rowspan = 1;
                    }
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 207..213

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 68.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                    jQuery(wym._box).find(
                        tableEditor._options.sAddRowButtonSelector
                    ).click(function () {
                        return tableEditor.addRow(wym.selectedContainer());
                    });
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 143..147
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 148..152

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 58.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                    jQuery(wym._box).find(
                        tableEditor._options.sRemoveRowButtonSelector
                    ).click(function () {
                        return tableEditor.removeRow(wym.selectedContainer());
                    });
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 138..142
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 148..152

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 58.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                    jQuery(wym._box).find(
                        tableEditor._options.sAddColumnButtonSelector
                    ).click(function () {
                        return tableEditor.addColumn(wym.selectedContainer());
                    });
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 138..142
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 143..147

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 58.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                        sAddColumnButtonHtml: String() +
                            "<li class='wym_tools_add_column'>" +
                                "<a name='add_column' href='#' " +
                                    "title='Add Column' " +
                                    "style='background-image: " +
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 30..39
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 42..51
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 66..75

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 56.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                        sRemoveColumnButtonHtml: String() +
                            "<li class='wym_tools_remove_column'>" +
                                "<a name='remove_column' href='#' " +
                                    "title='Remove Column' " +
                                    "style='background-image: " +
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 30..39
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 42..51
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 54..63

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 56.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                        sRemoveRowButtonHtml: String() +
                            "<li class='wym_tools_remove_row'>" +
                                "<a name='remove_row' href='#' " +
                                    "title='Remove Row' " +
                                    "style='background-image: " +
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 30..39
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 54..63
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 66..75

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 56.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        sMergeRowButtonHtml: String() +
                            '<li class="wym_tools_merge_row">' +
                                '<a name="merge_row" href="#" title="Merge Cells" ' +
                                    'style="background-image: ' +
                                        "url('" + wym._options.basePath +
                app/assets/javascripts/caseadilla/wymeditor/plugins/structured_headings/jquery.wymeditor.structured_headings.js on lines 74..82

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 56.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                        sAddRowButtonHtml: String() +
                            "<li class='wym_tools_add_row'>" +
                                "<a name='add_row' href='#' " +
                                    "title='Add Row' " +
                                    "style='background-image:" +
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 42..51
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 54..63
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 66..75

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 56.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                WYMeditor.editor.prototype.table = function (options) {
                    var wym = this,
                        tableEditor = new TableEditor(options, wym);
                    wym.tableEditor = tableEditor;
                
                
                app/assets/javascripts/caseadilla/wymeditor/plugins/structured_headings/jquery.wymeditor.structured_headings.js on lines 506..512

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 55.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    jQuery(wym._box).find(
                        tableEditor._options.sMergeRowButtonSelector
                    ).click(function () {
                        tableEditor.mergeRow();
                        return false;
                app/assets/javascripts/caseadilla/wymeditor/plugins/tidy/jquery.wymeditor.tidy.js on lines 42..49

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 55.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    jQuery(rootTr).children('td,th').each(function (index, elmnt) {
                        rowColCount += TableEditor.GET_COLSPAN_PROP(elmnt);
                    });
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 260..262

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 45.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    jQuery(parentTr).children('td,th').each(function (index, elmnt) {
                        rowColCount += TableEditor.GET_COLSPAN_PROP(elmnt);
                    });
                app/assets/javascripts/caseadilla/wymeditor/plugins/table/jquery.wymeditor.table.js on lines 353..355

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 45.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                There are no issues that match your filters.

                Category
                Status