EHadoux/aptimizer

View on GitHub
lib/aptimizer/objects/optimizer.rb

Summary

Maintainability
F
3 days
Test Coverage

Method remove_incompatible_initial has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    def remove_incompatible_initial(aps, verbose)
      if verbose
        puts "\n--> Applying incompatible initial arguments optimization:"
      end
      checker = ->(rules, type, suffix, initial) do
Severity: Minor
Found in lib/aptimizer/objects/optimizer.rb - About 5 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 remove_enthymemes has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    def remove_enthymemes(aps, verbose)
      if verbose
        puts "\n--> Applying enthymemes optimization:"
      end
      removed = []
Severity: Minor
Found in lib/aptimizer/objects/optimizer.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

Method fill_usage_hashes has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def fill_usage_hashes(aps)
      @premises_hash = Hash.new(nil)
      @modif_hash    = Hash.new(nil)
      @user_hash     = Hash.new(nil)

Severity: Minor
Found in lib/aptimizer/objects/optimizer.rb - About 3 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 remove_enthymemes has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def remove_enthymemes(aps, verbose)
      if verbose
        puts "\n--> Applying enthymemes optimization:"
      end
      removed = []
Severity: Minor
Found in lib/aptimizer/objects/optimizer.rb - About 1 hr to fix

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

        def prune_empty_rules(aps, verbose)
          if verbose
            puts "\n--> Pruning empty rules:"
          end
    
    
    Severity: Minor
    Found in lib/aptimizer/objects/optimizer.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 remove_dominated has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def remove_dominated(aps, verbose)
          if verbose
            puts "\n--> Applying dominated arguments optimization:"
          end
          graph = AtkGraph::Graph.new
    Severity: Minor
    Found in lib/aptimizer/objects/optimizer.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 remove_irrelevant_args has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def remove_irrelevant_args(aps, verbose)
          if verbose
            puts "\n--> Applying irrelevant arguments optimization:"
          end
          remove = ->(set, num="") do
    Severity: Minor
    Found in lib/aptimizer/objects/optimizer.rb - About 1 hr to fix

      Method remove_incompatible_initial has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def remove_incompatible_initial(aps, verbose)
            if verbose
              puts "\n--> Applying incompatible initial arguments optimization:"
            end
            checker = ->(rules, type, suffix, initial) do
      Severity: Minor
      Found in lib/aptimizer/objects/optimizer.rb - About 1 hr to fix

        Method remove_dominated has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def remove_dominated(aps, verbose)
              if verbose
                puts "\n--> Applying dominated arguments optimization:"
              end
              graph = AtkGraph::Graph.new
        Severity: Minor
        Found in lib/aptimizer/objects/optimizer.rb - About 1 hr to fix

          Method fill_usage_hashes has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def fill_usage_hashes(aps)
                @premises_hash = Hash.new(nil)
                @modif_hash    = Hash.new(nil)
                @user_hash     = Hash.new(nil)
          
          
          Severity: Minor
          Found in lib/aptimizer/objects/optimizer.rb - About 1 hr to fix

            Method remove_irrelevant_args has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def remove_irrelevant_args(aps, verbose)
                  if verbose
                    puts "\n--> Applying irrelevant arguments optimization:"
                  end
                  remove = ->(set, num="") do
            Severity: Minor
            Found in lib/aptimizer/objects/optimizer.rb - About 55 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 optimize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def optimize(aps, verbose=true, cycle=true, optimizations=[])
                  aps if optimizations.include?(:none)
                  flags_list = [:irrelevant, :initial, :enthymeme, :dominated]
                  (f = (optimizations - flags_list)) and (raise "Unknown flags :#{f} Known flags are #{flags_list}" unless f.empty?)
                  optimizations = flags_list if optimizations.empty?
            Severity: Minor
            Found in lib/aptimizer/objects/optimizer.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

            There are no issues that match your filters.

            Category
            Status