gogotanaka/Hilbert

View on GitHub

Showing 16 of 16 total issues

Method execute has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def execute(lexed)
      time = Time.now
      until lexed.token_str =~ /\A:(NLIN|R)\d+\z/

if Time.now > time + 10
Severity: Major
Found in lib/hilbert/parser.rb - About 2 hrs to fix

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

          def self.execute(str)
            lexed = Lexer::FormulaLexer.new(str)
            time = Time.now
            loop do
              if Time.now > time + 10
    Severity: Minor
    Found in lib/hilbert/parser/formula_parser.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

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

        def execute(lexed)
          time = Time.now
          until lexed.token_str =~ /\A:(NLIN|R)\d+\z/
    
    if Time.now > time + 10
    Severity: Minor
    Found in lib/hilbert/parser.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 execute has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.execute(str)
            lexed = Lexer::FormulaLexer.new(str)
            time = Time.now
            loop do
              if Time.now > time + 10
    Severity: Minor
    Found in lib/hilbert/parser/formula_parser.rb - About 1 hr to fix

      Function quadrature has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def quadrature(func, a, b, args=(), tol=1.49e-8, rtol=1.49e-8, maxiter=50,
      Severity: Major
      Found in legacy_rspec/langs/Python/ex1_after.py - About 1 hr to fix

        Function quadrature has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def quadrature(func, a, b, args=(), tol=1.49e-8, rtol=1.49e-8, maxiter=50,
        Severity: Major
        Found in legacy_rspec/langs/Python/ex1_before.py - About 1 hr to fix

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

                  def !@
                    if is_or?
                      if and_form = vars.find { |var| var.is_and? }
                        and_form.vars.map { |a| a + FORM.new((vars - [and_form]), :+) }.inject(:*)
                      elsif are_there_neg?
          Severity: Minor
          Found in lib/hilbert/world/propositional_logic.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

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

                def initialize(str)
                  ss = StringScanner.new(str)
                  @lexeds = []
                  until ss.eos?
                    scan_rslt, ss = scan(ss)
          Severity: Minor
          Found in lib/hilbert/lexer/base.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

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

          def fixed_quad(func,a,b,args=(),n=5):
          Severity: Minor
          Found in legacy_rspec/langs/Python/ex1_before.py - About 35 mins to fix

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

            def fixed_quad(func,a,b,args=(),n=5):
            Severity: Minor
            Found in legacy_rspec/langs/Python/ex1_after.py - About 35 mins to fix

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

                      def vfunc(x):
                          if isscalar(x):
                              return func(x, *args)
                          x = asarray(x)
                          # call with first point to get output type
              Severity: Minor
              Found in legacy_rspec/langs/Python/ex1_before.py - 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

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

                      def vfunc(x):
                          if isscalar(x):
                              return func(x, *args)
                          x = asarray(x)
                          # call with first point to get output type
              Severity: Minor
              Found in legacy_rspec/langs/Python/ex1_after.py - 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 output! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def output!
                      ch_compile_type(@args.first)
                      parse_string = parse(@args[1])
                      write!(@args[2], parse_string)
              
              
              Severity: Minor
              Found in lib/hilbert/exec.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

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

                  context 'into R' do
                    it do
                      expect(
                        Hilbert.to_r.compile('(1 2 3)')
                      ).to eq(
              Severity: Minor
              Found in legacy_rspec/objects/vector_spec.rb and 1 other location - About 25 mins to fix
              legacy_rspec/objects/matrix_spec.rb on lines 33..50

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

              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

                  context 'into Ruby' do
                    it do
                      expect(
                        Hilbert.to_ruby.compile('(1 2 3; 4 5 6)')
                      ).to eq(
              Severity: Minor
              Found in legacy_rspec/objects/matrix_spec.rb and 1 other location - About 25 mins to fix
              legacy_rspec/objects/vector_spec.rb on lines 5..22

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

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

                  def self.optimize_output(ruby_obj)
              
                    case ruby_obj
                    when Matrix, Vector, Dydx::Algebra::Formula
                      ruby_obj.to_q
              Severity: Minor
              Found in lib/hilbert/iq.rb - About 25 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