openjaf/cenit

View on GitHub
app/models/setup/algorithm.rb

Summary

Maintainability
D
2 days
Test Coverage

File algorithm.rb has 341 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rkelly'

module Setup
  class Algorithm
    include SnippetCode
Severity: Minor
Found in app/models/setup/algorithm.rb - About 4 hrs to fix

    Method do_store_output has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def do_store_output(output)
          rc = []
          r = nil
    
          while output.capataz_proxy?
    Severity: Minor
    Found in app/models/setup/algorithm.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 run has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def run(input = [], task = nil)
          input = Cenit::Utility.json_value_of(input)
          input = [input] unless input.is_a?(Array)
          input = input.dup
          input_size = input.length
    Severity: Minor
    Found in app/models/setup/algorithm.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

    Class Algorithm has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Algorithm
        include SnippetCode
        include NamespaceNamed
        include Taggable
        # = Algorithm
    Severity: Minor
    Found in app/models/setup/algorithm.rb - About 3 hrs to fix

      Method do_store_output has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def do_store_output(output)
            rc = []
            r = nil
      
            while output.capataz_proxy?
      Severity: Major
      Found in app/models/setup/algorithm.rb - About 2 hrs to fix

        Method run has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def run(input = [], task = nil)
              input = Cenit::Utility.json_value_of(input)
              input = [input] unless input.is_a?(Array)
              input = input.dup
              input_size = input.length
        Severity: Minor
        Found in app/models/setup/algorithm.rb - About 1 hr to fix

          Method validate_code has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def validate_code
                if code.blank?
                  errors.add(:code, "can't be blank")
                else
                  logs = parse_code
          Severity: Minor
          Found in app/models/setup/algorithm.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 validate_parameters has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def validate_parameters
                not_required = false
                parameters.each do |p|
                  next unless not_required ||= !p.required
                  p.errors.add(:required, 'marked as "Required" must come before non marked') if p.required
          Severity: Minor
          Found in app/models/setup/algorithm.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 parse_code has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_code
                if language == :auto
                  logs = {}
                  lang = self.class.language_enum.values.detect do |language|
                    next if language == :auto
          Severity: Minor
          Found in app/models/setup/algorithm.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 for_each_call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def for_each_call(visited = Set.new, &block)
                unless visited.include?(self)
                  visited << self
                  block.call(self) if block
                  call_links.each { |call_link| call_link.link.for_each_call(visited, &block) if call_link.link }
          Severity: Minor
          Found in app/models/setup/algorithm.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 parse_javascript_code has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_javascript_code
                logs = { errors: errors = [] }
                ast =
                  begin
                    RKelly.parse(code)
          Severity: Minor
          Found in app/models/setup/algorithm.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 run_asynchronous has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def run_asynchronous(*args, &block)
                options =
                  if args.last.is_a?(Hash)
                    args.pop
                  else
          Severity: Minor
          Found in app/models/setup/algorithm.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

          There are no issues that match your filters.

          Category
          Status