jmuheim/base

View on GitHub

Showing 34 of 34 total issues

File diff_match_patch.js has 641 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function() {
    function diff_match_patch() {
        this.Diff_Timeout = 1;
        this.Diff_EditCost = 4;
        this.Match_Threshold = 0.5;
Severity: Major
Found in app/assets/javascripts/diff_match_patch.js - About 1 day to fix

    Method complete_internal_references has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

      def complete_internal_references(resource, attribute_name)
        resource.send(attribute_name).to_s.lines.map do |line|
          line.gsub!(/\[(.*?)\]\((@(.+?)-(.+?))\)/) do
            caption = $1
            url     = $2
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 4 hrs to fix

    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

                "" === e[4] ? (f.start2--, f.length2 = 1) : "0" == e[4] ? f.length2 = 0 : (f.start2--, f.length2 =
                    parseInt(e[4], 10));
    Severity: Major
    Found in app/assets/javascripts/diff_match_patch.js and 1 other location - About 2 hrs to fix
    app/assets/javascripts/diff_match_patch.js on lines 590..590

    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 82.

    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

                "" === e[2] ? (f.start1--, f.length1 = 1) : "0" == e[2] ? f.length1 = 0 : (f.start1--, f.length1 = parseInt(e[2], 10));
    Severity: Major
    Found in app/assets/javascripts/diff_match_patch.js and 1 other location - About 2 hrs to fix
    app/assets/javascripts/diff_match_patch.js on lines 592..593

    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 82.

    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

    Method validate_each has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      def validate_each(record, attribute, value)
        raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.kind_of? CarrierWave::Uploader::Base
        
        value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String)
    
    
    Severity: Minor
    Found in app/validators/file_size_validator.rb - About 2 hrs to fix

    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

            a = 0 === this.length1 ? this.start1 + ",0" : 1 == this.length1 ? this.start1 + 1 : this.start1 + 1 + "," + this.length1;
    Severity: Major
    Found in app/assets/javascripts/diff_match_patch.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/diff_match_patch.js on lines 619..619

    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 71.

    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

                    m = n == -v || n != v && j[l - 1] < j[l + 1] ? j[l + 1] : j[l - 1] + 1;
    Severity: Major
    Found in app/assets/javascripts/diff_match_patch.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/diff_match_patch.js on lines 112..112

    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 71.

    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

            b = 0 === this.length2 ? this.start2 + ",0" : 1 == this.length2 ? this.start2 + 1 : this.start2 + 1 + "," + this.length2;
    Severity: Major
    Found in app/assets/javascripts/diff_match_patch.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/diff_match_patch.js on lines 618..618

    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 71.

    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

                    u = n == -v || n != v && i[l - 1] < i[l + 1] ? i[l + 1] : i[l - 1] + 1;
    Severity: Major
    Found in app/assets/javascripts/diff_match_patch.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/diff_match_patch.js on lines 99..99

    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 71.

    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

    Method indent_heading_level has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      def indent_heading_level(markdown, heading_level, visual_heading_level = nil)
        markdown.to_s.lines.map do |line|
          line = line.rstrip # Remove all new line stuff (\n, \r)
    
          if matches = line.match(/^([#]+)(.*)$/)
    Severity: Minor
    Found in app/helpers/markdown_helper.rb - About 1 hr to fix

    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

    Consider simplifying this complex logical expression.
    Open

                if (!(a[c].length1 <= b)) {
                    var d = a[c];
                    a.splice(c--, 1);
                    for (var e = d.start1, f = d.start2, g = ""; 0 !== d.diffs.length;) {
                        var h = new diff_match_patch.patch_obj,
    Severity: Critical
    Found in app/assets/javascripts/diff_match_patch.js - About 1 hr to fix

      Method complete_internal_references has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def complete_internal_references(resource, attribute_name)
          resource.send(attribute_name).to_s.lines.map do |line|
            line.gsub!(/\[(.*?)\]\((@(.+?)-(.+?))\)/) do
              caption = $1
              url     = $2
      Severity: Minor
      Found in app/helpers/application_helper.rb - About 1 hr to fix

        Function diff_cleanupSemanticLossless has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            diff_match_patch.prototype.diff_cleanupSemanticLossless = function(a) {
                function b(a, b) {
                    if (!a || !b) return 6;
                    var c = a.charAt(a.length - 1),
                        d = b.charAt(0),
        Severity: Minor
        Found in app/assets/javascripts/diff_match_patch.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                      else if (-1 == a[f][0] ? i = !0 : j = !0, e && (g && h && j && i || e.length < this.Diff_EditCost / 2 && 3 == g + h + j + i)) a.splice(c[d - 1], 0, [-1, e]), a[c[d - 1] + 1][0] = 1, d--, e = null, g && h ? (j = i = !0, d = 0) : (d--, f = 0 < d ? c[d - 1] : -1, j = i = !1), b = !0;
          Severity: Critical
          Found in app/assets/javascripts/diff_match_patch.js - About 1 hr to fix

            Function diff_lineMode_ has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                diff_match_patch.prototype.diff_lineMode_ = function(a, b, c) {
                    var d = this.diff_linesToChars_(a, b);
                    a = d.chars1;
                    b = d.chars2;
                    d = d.lineArray;
            Severity: Minor
            Found in app/assets/javascripts/diff_match_patch.js - About 1 hr to fix

              Function diff_bisect_ has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  diff_match_patch.prototype.diff_bisect_ = function(a, b, c) {
                      for (var d = a.length, e = b.length, f = Math.ceil((d + e) / 2), g = f, h = 2 * f, j = Array(h), i = Array(h), k = 0; k < h; k++) j[k] = -1, i[k] = -1;
                      j[g + 1] = 0;
                      i[g + 1] = 0;
                      for (var k = d - e, q = 0 != k % 2, r = 0, t = 0, p = 0, w = 0, v = 0; v < f && !((new Date).getTime() > c); v++) {
              Severity: Minor
              Found in app/assets/javascripts/diff_match_patch.js - About 1 hr to fix

                Function patch_make has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    diff_match_patch.prototype.patch_make = function(a, b, c) {
                        var d;
                        if ("string" == typeof a && "string" == typeof b && "undefined" == typeof c) d = a, b = this.diff_main(d, b, !0), 2 < b.length && (this.diff_cleanupSemantic(b), this.diff_cleanupEfficiency(b));
                        else if (a && "object" == typeof a && "undefined" == typeof b && "undefined" == typeof c) b = a, d = this.diff_text1(b);
                        else if ("string" == typeof a && b && "object" == typeof b && "undefined" == typeof c) d = a;
                Severity: Minor
                Found in app/assets/javascripts/diff_match_patch.js - About 1 hr to fix

                  Function patch_fromText has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      diff_match_patch.prototype.patch_fromText = function(a) {
                          var b = [];
                          if (!a) return b;
                          a = a.split("\n");
                          for (var c = 0, d = /^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/; c < a.length;) {
                  Severity: Minor
                  Found in app/assets/javascripts/diff_match_patch.js - About 1 hr to fix

                    Function match_bitap_ has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        diff_match_patch.prototype.match_bitap_ = function(a, b, c) {
                            function d(a, d) {
                                var e = a / b.length,
                                    g = Math.abs(c - d);
                                return !f.Match_Distance ? g ? 1 : e : e + g / f.Match_Distance
                    Severity: Minor
                    Found in app/assets/javascripts/diff_match_patch.js - About 1 hr to fix

                      Method icon_for has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def icon_for(extension)
                          if ['zip', 'rar', '7z', '7zip', 'gzip'].include? extension
                            'file-archive-o'
                          elsif ['mp3', 'wav'].include? extension
                            'file-audio-o'
                      Severity: Minor
                      Found in app/inputs/upload_input.rb - About 1 hr to fix

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language