maki-tetsu/anodator

View on GitHub

Showing 191 of 191 total issues

Cyclomatic complexity for load_rule_from_csv_file is too high. [9/6]
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 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. [13/10]
Open

    def self.options_reader(row, options = {}, options_index_from = 4)
      if row.size > options_index_from
        row[options_index_from..-1].each do |column|
          next if column.nil?
          key, value = column.split(':', 2)
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 add_error_level is too high. [8/6]
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 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.

Assignment Branch Condition size for generate_data is too high. [17.12/15]
Open

    def generate_data(input_spec_with_values, check_results)
      buf = []
      buf << @items.map do |item|
        if item.is_a? Symbol
          case item
Severity: Minor
Found in lib/anodator/output_spec.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. [12/10]
Open

    def initialize(number, name, type = TYPE_STRING)
      if number.nil? || number.to_s.split(//).size.zero?
        raise ArgumentError, 'number cannot be blank'
      end
      if name.nil? || name.to_s.split(//).size.zero?
Severity: Minor
Found in lib/anodator/input_spec_item.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. [12/10]
Open

    def initialize(target_numbers, message, level)
      @target_numbers = [target_numbers].flatten
      @message        = message.to_s
      @level          = level

Severity: Minor
Found in lib/anodator/check_result.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. [12/10]
Open

    def self.load_input_spec_from_csv_file(file_path)
      first = true
      header = nil
      spec = []
      CSV.read(file_path).each do |row|
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.

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

    def check_all
      @results = []

      if @rules.count.zero?
        return false
Severity: Minor
Found in lib/anodator/rule_set.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 generate_data is too high. [7/6]
Open

    def generate_data(input_spec_with_values, check_results)
      buf = []
      buf << @items.map do |item|
        if item.is_a? Symbol
          case item
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.

Assignment Branch Condition size for initialize is too high. [16.43/15]
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 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

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

      def validate
        if target_value.split(//).size.zero?
          return true if allow_blank?
        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

Perceived complexity for add_error_level is too high. [8/7]
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 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. [11/10]
Open

      def value
        if indirect?
          if data_source?
            @validator.data_source_at(@value[0].value,
                                      @value[1].value,

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.

Assignment Branch Condition size for initialize is too high. [15.17/15]
Open

    def initialize(number, name, type = TYPE_STRING)
      if number.nil? || number.to_s.split(//).size.zero?
        raise ArgumentError, 'number cannot be blank'
      end
      if name.nil? || name.to_s.split(//).size.zero?
Severity: Minor
Found in lib/anodator/input_spec_item.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

Assignment Branch Condition size for load_output_spec_from_csv_file is too high. [15.17/15]
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 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 load_validators_from_csv_file has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

Severity: Minor
Found in lib/anodator/utils.rb - About 1 hr to fix

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

        def self.load_validators_from_csv_file(file_path)
          first = true
          header = nil
          validators = {}
    
    
    Severity: Minor
    Found in lib/anodator/utils.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 load_rule_from_csv_file has 39 lines of code (exceeds 25 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 1 hr to fix

      Method add_error_level has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      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 - 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 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def validate
              if target_value.split(//).size.zero?
                return true if allow_blank?
              end
      
      
      Severity: Minor
      Found in lib/anodator/validator/format_validator.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

      Severity
      Category
      Status
      Source
      Language