skippyPeanutButter/yaml_bot

View on GitHub

Showing 4 of 4 total issues

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

    def self.get_object_value(yaml, key_addr)
      if !key_addr.index('.').nil? && key_addr.index('.') >= 0
        key1, key2 = key_addr.split('.', 2)
        return get_object_value(yaml[key1], key2) if !yaml[key1].nil? && yaml[key1].instance_of?(Hash)
        return nil
Severity: Minor
Found in lib/yaml_bot/parse_bot.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 check_and_requires has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def check_and_requires
      yaml_key = ParseBot.get_object_value(yaml_file, key['key'])
      return if yaml_key.nil? || key['and_requires'].nil?
      key['and_requires'].each do |k|
        next unless ParseBot.get_object_value(yaml_file, k).nil?
Severity: Minor
Found in lib/yaml_bot/key_bot.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 load_yaml has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def load_yaml
      raise StandardError, 'No YAML file specified' if @options[:file].nil?
      raise IOError unless File.exist?(@options[:file])
      @validation_bot.yaml_file = YAML.load_file(@options[:file])
    rescue IOError
Severity: Minor
Found in lib/yaml_bot/cli_bot.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

Method validate_rules has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_rules
      raise ValidationError, '.yamlbot rules file is not set.' if @rules.nil?
      raise ValidationError, 'rules section not defined in .yamlbot file' if @rules['rules'].nil?
      validate_rules_keys(@rules['defaults']) unless @rules['defaults'].nil?
      if @rules['rules'].instance_of?(Array)
Severity: Minor
Found in lib/yaml_bot/rules_bot.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

Severity
Category
Status
Source
Language