app/models/rule_types/base_rule_type.rb

Summary

Maintainability
A
55 mins
Test Coverage
A
90%

Method has too many lines. [14/10]
Open

    def refactor(formula, new_code)
      used_by = used_by_formulas(formula)

      used_by.each do |used_by_formula|
        tokens = Orbf::RulesEngine::Tokenizer.tokenize(used_by_formula.expression)

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

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

    def refactor(formula, new_code)
      used_by = used_by_formulas(formula)

      used_by.each do |used_by_formula|
        tokens = Orbf::RulesEngine::Tokenizer.tokenize(used_by_formula.expression)
Severity: Minor
Found in app/models/rule_types/base_rule_type.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

Do not write to stdout. Use Rails's logger if you want to log.
Open

          puts "refactoring formula #{used_by_formula.id} : #{used_by_formula.code} := #{used_by_formula.expression} to #{new_expression}"

This cop checks for the use of output calls like puts and print

Example:

# bad
puts 'A debug message'
pp 'A debug message'
print 'A debug message'

# good
Rails.logger.debug 'A debug message'

Do not write to stdout. Use Rails's logger if you want to log.
Open

          puts "updating exportable_formula_code #{used_by_formula.id} : #{used_by_formula.exportable_formula_code} to #{new_code}"

This cop checks for the use of output calls like puts and print

Example:

# bad
puts 'A debug message'
pp 'A debug message'
print 'A debug message'

# good
Rails.logger.debug 'A debug message'

Line is too long. [131/100]
Open

          puts "updating exportable_formula_code #{used_by_formula.id} : #{used_by_formula.exportable_formula_code} to #{new_code}"

Line is too long. [138/100]
Open

          puts "refactoring formula #{used_by_formula.id} : #{used_by_formula.code} := #{used_by_formula.expression} to #{new_expression}"

Line is too long. [118/100]
Open

        if used_by_formula.exportable_formula_code.presence && used_by_formula.exportable_formula_code == formula.code

Missing magic comment # frozen_string_literal: true.
Open

module RuleTypes

This cop is designed to help upgrade to after Ruby 3.0. It will add the comment # frozen_string_literal: true to the top of files to enable frozen string literals. Frozen string literals may be default after Ruby 3.0. The comment will be added below a shebang and encoding comment. The frozen string literal comment is only valid in Ruby 2.3+.

Example: EnforcedStyle: always (default)

# The `always` style will always add the frozen string literal comment
# to a file, regardless of the Ruby version or if `freeze` or `<<` are
# called on a string literal.
# bad
module Bar
  # ...
end

# good
# frozen_string_literal: true

module Bar
  # ...
end

Example: EnforcedStyle: never

# The `never` will enforce that the frozen string literal comment does
# not exist in a file.
# bad
# frozen_string_literal: true

module Baz
  # ...
end

# good
module Baz
  # ...
end

There are no issues that match your filters.

Category
Status