maki-tetsu/anodator

View on GitHub

Showing 191 of 191 total issues

Cyclomatic complexity for generate_error is too high. [16/6]
Open

    def generate_error(input_spec_with_values, check_results)
      buf = []

      if check_results.size.zero?
        if @include_no_error
Severity: Minor
Found in lib/anodator/output_spec.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method load_rule_from_csv_file has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def self.load_rule_from_csv_file(file_path, validators)
      first = true
      header = nil
      rule_set = RuleSet.new

Severity: Minor
Found in lib/anodator/utils.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

Perceived complexity for validate is too high. [14/7]
Open

      def validate
        if allow_blank?
          return true if target_value.split(//).size.zero?
        end

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

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

    def initialize(target_expressions, message, validator, prerequisite = nil, level = ERROR_LEVELS.values.sort.last, description = nil)
      @target_expressions = [target_expressions].flatten
      @message            = message
      @validator          = validator
      @prerequisite       = prerequisite
Severity: Minor
Found in lib/anodator/rule.rb by rubocop

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 has too many lines. [17/10]
Open

      def validate
        if @options[:validators].nil?
          raise ConfigurationError, 'ComplexValidator must have validators option'
        end
        case @options[:logic]

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.

Cyclomatic complexity for load_validators_from_csv_file is too high. [13/6]
Open

    def self.load_validators_from_csv_file(file_path)
      first = true
      header = nil
      validators = {}

Severity: Minor
Found in lib/anodator/utils.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Perceived complexity for generate_error is too high. [13/7]
Open

    def generate_error(input_spec_with_values, check_results)
      buf = []

      if check_results.size.zero?
        if @include_no_error
Severity: Minor
Found in lib/anodator/output_spec.rb by rubocop

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Assignment Branch Condition size for validate is too high. [21.12/15]
Open

      def validate
        length = target_value.split(//).size

        if allow_blank?
          return true if length.zero?

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

    def self.load_output_spec_from_csv_file(file_path,
                                            target = Anodator::OutputSpec::TARGET_ERROR,
                                            include_no_error = false)
      first = true
      header = nil
Severity: Minor
Found in lib/anodator/utils.rb by rubocop

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.

Cyclomatic complexity for validate is too high. [12/6]
Open

      def validate
        length = target_value.split(//).size

        if allow_blank?
          return true if length.zero?

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

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

      def validate
        if target_value.split(//).size.zero?
          return true if allow_blank?
        end

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 has too many lines. [15/10]
Open

      def initialize(value, validator)
        @value = value
        @validator = validator
        @indirect = false
        @data_source = false

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 generate_error has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def generate_error(input_spec_with_values, check_results)
      buf = []

      if check_results.size.zero?
        if @include_no_error
Severity: Major
Found in lib/anodator/output_spec.rb - About 2 hrs to fix

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

            def default_options(options = nil)
              # initialize from superclass
              @default_options = superclass.default_options if @default_options.nil?
    
              unless options.nil?
    Severity: Minor
    Found in lib/anodator/validator/base.rb by rubocop

    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.

    Perceived complexity for load_rule_from_csv_file is too high. [11/7]
    Open

        def self.load_rule_from_csv_file(file_path, validators)
          first = true
          header = nil
          rule_set = RuleSet.new
    
    
    Severity: Minor
    Found in lib/anodator/utils.rb by rubocop

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

    Perceived complexity for validate is too high. [11/7]
    Open

          def validate
            length = target_value.split(//).size
    
            if allow_blank?
              return true if length.zero?

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

    Assignment Branch Condition size for add_error_level is too high. [18.49/15]
    Open

        def self.add_error_level(value, symbol, label)
          # value check
          raise 'Error level value must be Integer' unless value.is_a? Integer
          raise 'Error level value must be greater than zero' unless value > 0
          raise "Error level value #{value} already exists" if ERROR_LEVELS.values.include?(value)
    Severity: Minor
    Found in lib/anodator/rule.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

        def expand(data_provider)
          @template.gsub(/\[\[([^:]+)::([^\]]+)\]\]/) do
            spec_item = data_provider.spec_item_by_expression(Regexp.last_match(1))
            case Regexp.last_match(2)
            when 'name'
    Severity: Minor
    Found in lib/anodator/message.rb by rubocop

    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 has too many lines. [13/10]
    Open

        def check
          unless @prerequisite.nil?
            return nil unless @prerequisite.valid?
          end
    
    
    Severity: Minor
    Found in lib/anodator/rule.rb by rubocop

    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 has too many lines. [13/10]
    Open

            def valid_option_keys(*option_keys)
              # initialize from superclass
              if @valid_option_keys.nil?
                @valid_option_keys = superclass.valid_option_keys
              end
    Severity: Minor
    Found in lib/anodator/validator/base.rb by rubocop

    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.

    Severity
    Category
    Status
    Source
    Language