openjaf/cenit

View on GitHub
app/models/concerns/setup/translation_common.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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

    def run(message)
      if (translator = agent_from_msg)
        unless message[:options].is_a?(Hash)
          begin
            message[:options] = self.class.parse_options(message[:options].to_s)
Severity: Minor
Found in app/models/concerns/setup/translation_common.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 parse_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def parse_options(options)
        options = options.to_s.strip
        options = "{#{options}" unless options.start_with?('{')
        options = "#{options}}" unless options.ends_with?('}')
        ast =
Severity: Minor
Found in app/models/concerns/setup/translation_common.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 check_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def check_hash(ast)
        ast.children.each do |child|
          fail 'have not a valid options Hash format.' unless child.type == :pair
          unless [:sym, :str].include?(child.children[0].type)
            fail "contains a non valid key '#{child.children[0].location.expression.source}'"
Severity: Minor
Found in app/models/concerns/setup/translation_common.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