MatteoRagni/cas-rb

View on GitHub

Showing 1,530 of 1,530 total issues

Method reduce_associativity has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def reduce_associativity
      pos, neg = [], []

      @x.each do |x_el|
        case x_el
Severity: Minor
Found in lib/functions/fnc-sum.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

Function performSearch has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function performSearch(data, regexps, queries, highlighters, state) {
    var searchIndex = data.searchIndex;
    var longSearchIndex = data.longSearchIndex;
    var info = data.info;
    var result = [];
Severity: Minor
Found in docs/js/searcher.js - About 1 hr to fix

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

        def subs_rhs(dt)
          CAS::Help.assert(dt, Hash)
          sub = dt.keys.select { |e| e == @y }[0]
          if sub
            if dt[sub].is_a? CAS::Op
    Severity: Major
    Found in lib/operators/bary-op.rb and 1 other location - About 1 hr to fix
    lib/operators/bary-op.rb on lines 103..117

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

    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

        def subs_lhs(dt)
          CAS::Help.assert(dt, Hash)
          sub = dt.keys.select { |e| e == @x }[0]
          if sub
            if dt[sub].is_a? CAS::Op
    Severity: Major
    Found in lib/operators/bary-op.rb and 1 other location - About 1 hr to fix
    lib/operators/bary-op.rb on lines 124..138

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

    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 simplify has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def simplify
          super
          return self if (@x == CAS::Zero and @y == CAS::Zero)
          return self if (@x == CAS::Infinity and @y == CAS::Infinity)
          return self if (@x == CAS::Infinity and @y == CAS::Zero)
    Severity: Minor
    Found in lib/functions/fnc-base.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

    Method to_dot has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.to_dot(op)
        CAS::Help.assert(op, CAS::Op)
        string = op.dot_graph
        labels = ""
    
    
    Severity: Minor
    Found in lib/Mr.CAS/graphviz.rb - About 1 hr to fix

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

          def simplify
            super
            return self if (@x == CAS::Zero and @y == CAS::Zero)
            return self if (@x == CAS::Infinity and @y == CAS::Infinity)
            return self if (@x == CAS::Infinity and @y == CAS::Zero)
      Severity: Minor
      Found in lib/functions/fnc-base.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

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

        this.onkeydown = function(e) {
          if (!this.navigationActive) return;
          switch(e.keyCode) {
            case 37: //Event.KEY_LEFT:
              if (this.moveLeft()) e.preventDefault();
      Severity: Minor
      Found in docs/js/navigation.js - About 1 hr to fix

        Method subs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def subs(dt)
              CAS::Help.assert(dt, Hash)
              @x = @x.map { |z| z.subs(dt) || z }
              @x.each_with_index do |x, k|
                sub = dt.keys.select { |e| e == x }[0]
        Severity: Minor
        Found in lib/operators/nary-op.rb - About 45 mins 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 8 locations. Consider refactoring.
        Open

          class Acos
            def to_ascii
              x_ascii, x_baseline = @x.to_ascii
              x_ascii = CAS::Ascii.normalize_ascii(x_ascii, (self.to_ascii_x_vars_complexity ? :complex : :simple))
              x_ascii = x_ascii.map.with_index do |l, i|
        Severity: Major
        Found in bin/graph2ascii.rb and 7 other locations - About 40 mins to fix
        bin/graph2ascii.rb on lines 163..169
        bin/graph2ascii.rb on lines 203..211
        bin/graph2ascii.rb on lines 215..223
        bin/graph2ascii.rb on lines 227..235
        bin/graph2ascii.rb on lines 239..247
        bin/graph2ascii.rb on lines 263..271
        bin/graph2ascii.rb on lines 296..304

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

        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 8 locations. Consider refactoring.
        Open

          class Log
            def to_ascii
              x_ascii, x_baseline = @x.to_ascii
              x_ascii = CAS::Ascii.normalize_ascii(x_ascii, (self.to_ascii_x_vars_complexity ? :complex : :simple))
              x_ascii = x_ascii.map.with_index do |l, i|
        Severity: Major
        Found in bin/graph2ascii.rb and 7 other locations - About 40 mins to fix
        bin/graph2ascii.rb on lines 163..169
        bin/graph2ascii.rb on lines 203..211
        bin/graph2ascii.rb on lines 215..223
        bin/graph2ascii.rb on lines 227..235
        bin/graph2ascii.rb on lines 239..247
        bin/graph2ascii.rb on lines 251..259
        bin/graph2ascii.rb on lines 263..271

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

        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 8 locations. Consider refactoring.
        Open

          class Invert
            def to_ascii
              x_ascii, x_bl = @x.to_ascii
              x_ascii = CAS::Ascii.normalize_ascii(x_ascii, (self.to_ascii_x_vars_complexity ? :complex : :simple))
        
        
        Severity: Major
        Found in bin/graph2ascii.rb and 7 other locations - About 40 mins to fix
        bin/graph2ascii.rb on lines 203..211
        bin/graph2ascii.rb on lines 215..223
        bin/graph2ascii.rb on lines 227..235
        bin/graph2ascii.rb on lines 239..247
        bin/graph2ascii.rb on lines 251..259
        bin/graph2ascii.rb on lines 263..271
        bin/graph2ascii.rb on lines 296..304

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

        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 8 locations. Consider refactoring.
        Open

          class Sin
            def to_ascii
              x_ascii, x_baseline = @x.to_ascii
              x_ascii = CAS::Ascii.normalize_ascii(x_ascii, (self.to_ascii_x_vars_complexity ? :complex : :simple))
              x_ascii = x_ascii.map.with_index do |l, i|
        Severity: Major
        Found in bin/graph2ascii.rb and 7 other locations - About 40 mins to fix
        bin/graph2ascii.rb on lines 163..169
        bin/graph2ascii.rb on lines 215..223
        bin/graph2ascii.rb on lines 227..235
        bin/graph2ascii.rb on lines 239..247
        bin/graph2ascii.rb on lines 251..259
        bin/graph2ascii.rb on lines 263..271
        bin/graph2ascii.rb on lines 296..304

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

        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 8 locations. Consider refactoring.
        Open

          class Atan
            def to_ascii
              x_ascii, x_baseline = @x.to_ascii
              x_ascii = CAS::Ascii.normalize_ascii(x_ascii, (self.to_ascii_x_vars_complexity ? :complex : :simple))
              x_ascii = x_ascii.map.with_index do |l, i|
        Severity: Major
        Found in bin/graph2ascii.rb and 7 other locations - About 40 mins to fix
        bin/graph2ascii.rb on lines 163..169
        bin/graph2ascii.rb on lines 203..211
        bin/graph2ascii.rb on lines 215..223
        bin/graph2ascii.rb on lines 227..235
        bin/graph2ascii.rb on lines 239..247
        bin/graph2ascii.rb on lines 251..259
        bin/graph2ascii.rb on lines 296..304

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

        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 8 locations. Consider refactoring.
        Open

          class Asin
            def to_ascii
              x_ascii, x_baseline = @x.to_ascii
              x_ascii = CAS::Ascii.normalize_ascii(x_ascii, (self.to_ascii_x_vars_complexity ? :complex : :simple))
              x_ascii = x_ascii.map.with_index do |l, i|
        Severity: Major
        Found in bin/graph2ascii.rb and 7 other locations - About 40 mins to fix
        bin/graph2ascii.rb on lines 163..169
        bin/graph2ascii.rb on lines 203..211
        bin/graph2ascii.rb on lines 215..223
        bin/graph2ascii.rb on lines 227..235
        bin/graph2ascii.rb on lines 251..259
        bin/graph2ascii.rb on lines 263..271
        bin/graph2ascii.rb on lines 296..304

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

        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 8 locations. Consider refactoring.
        Open

          class Cos
            def to_ascii
              x_ascii, x_baseline = @x.to_ascii
              x_ascii = CAS::Ascii.normalize_ascii(x_ascii, (self.to_ascii_x_vars_complexity ? :complex : :simple))
              x_ascii = x_ascii.map.with_index do |l, i|
        Severity: Major
        Found in bin/graph2ascii.rb and 7 other locations - About 40 mins to fix
        bin/graph2ascii.rb on lines 163..169
        bin/graph2ascii.rb on lines 203..211
        bin/graph2ascii.rb on lines 227..235
        bin/graph2ascii.rb on lines 239..247
        bin/graph2ascii.rb on lines 251..259
        bin/graph2ascii.rb on lines 263..271
        bin/graph2ascii.rb on lines 296..304

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

        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 8 locations. Consider refactoring.
        Open

          class Tan
            def to_ascii
              x_ascii, x_baseline = @x.to_ascii
              x_ascii = CAS::Ascii.normalize_ascii(x_ascii, (self.to_ascii_x_vars_complexity ? :complex : :simple))
              x_ascii = x_ascii.map.with_index do |l, i|
        Severity: Major
        Found in bin/graph2ascii.rb and 7 other locations - About 40 mins to fix
        bin/graph2ascii.rb on lines 163..169
        bin/graph2ascii.rb on lines 203..211
        bin/graph2ascii.rb on lines 215..223
        bin/graph2ascii.rb on lines 239..247
        bin/graph2ascii.rb on lines 251..259
        bin/graph2ascii.rb on lines 263..271
        bin/graph2ascii.rb on lines 296..304

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

        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

        Function performSearch has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          function performSearch(data, regexps, queries, highlighters, state) {
        Severity: Minor
        Found in docs/js/searcher.js - About 35 mins to fix

          Method __reduce_multeplicity has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def __reduce_multeplicity(xs)
                count = Hash.new(0)
                xs.each do |x|
                  e = x
                  count.keys.each { |d| e = d if x == d  }
          Severity: Minor
          Found in lib/operators/nary-op.rb - About 35 mins 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

          Method simplify has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def simplify
                super
                return CAS.invert(@y) if @x == CAS::Zero
                return @x if @y == CAS::Zero
                return CAS::Zero if @x == @y
          Severity: Minor
          Found in lib/functions/fnc-base.rb - About 35 mins 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