codeclimate/codeclimate

View on GitHub

Showing 14 of 98 total issues

File html_formatter.rb has 318 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "redcarpet"

module CC
  module Analyzer
    module Formatters
Severity: Minor
Found in lib/cc/analyzer/formatters/html_formatter.rb - About 3 hrs to fix

    Method run has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def run(options = [])
            started = Time.now
    
            command = docker_run_command(options)
            Analyzer.logger.debug("docker run: #{command.inspect}")
    Severity: Minor
    Found in lib/cc/analyzer/container.rb - About 1 hr to fix

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

            def upconvert_legacy_yaml!
              config.delete("ratings")
      
              if config.key?("engines")
                config["plugins"] ||= config.delete("engines")
      Severity: Minor
      Found in lib/cc/config/yaml_adapter.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

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

                def check_validity
                  if location["lines"]
                    self.error = "location.lines is not valid: #{JSON.dump(location["lines"])}" unless valid_lines?(location["lines"])
                  elsif location["positions"]
                    self.error = "location.positions is not valid: #{JSON.dump(location["positions"])}" unless valid_positions?(location["positions"])
      Severity: Minor
      Found in lib/cc/analyzer/issue_validations/location_format_validation.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

      Method check has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def check
              return unless global_config.check_version? && version_check_is_due?
      
              print_new_version_message if outdated?
      
      
      Severity: Minor
      Found in lib/cc/cli/version_checker.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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def run
              formatter.started
      
              config.engines.each do |engine|
                next unless engine.enabled?
      Severity: Minor
      Found in lib/cc/analyzer/bridge.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 validate_path has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def validate_path(path)
                if path.nil? || path.length.zero?
                  errors << "fetch section's 'path' cannot be empty"
                else
                  pathname = Pathname.new(path)
      Severity: Minor
      Found in lib/cc/config/validation/fetch_validator.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 validate_exclude_pattern has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def validate_exclude_pattern(key, legacy: false)
                types =
                  if legacy
                    [Array, String]
                  else
      Severity: Minor
      Found in lib/cc/config/validation/file_validator.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 remove has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def remove(head = nil, *tail)
                return if head.nil? && tail.empty?
                populate_direct_children
      
                if (child = children[head])
      Severity: Minor
      Found in lib/cc/workspace/path_tree/dir_node.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 process_args has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def process_args
              while (arg = @args.shift)
                case arg
                when "-f", "--format"
                  @formatter = Formatters.resolve(@args.shift).new(filesystem)
      Severity: Minor
      Found in lib/cc/cli/analyze.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_key_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def validate_key_type(key, types)
                if types.is_a?(Class)
                  return validate_key_type(key, [types])
                elsif data.key?(key)
                  unless types.include?(data[key].class)
      Severity: Minor
      Found in lib/cc/config/validation/hash_validations.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 apply_default_engines has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def apply_default_engines
              config["plugins"] ||= {}
      
              ENGINES.each do |name, channel|
                config["plugins"][name] ||= {}
      Severity: Minor
      Found in lib/cc/config/default_adapter.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 to_offset has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def to_offset(line, column, offset = 0)
              source.each_line.with_index do |source_line, index|
                offset +=
                  if line == index
                    column
      Severity: Minor
      Found in lib/cc/analyzer/source_extractor.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 key_type_error_message has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def key_type_error_message(key, types)
                if types.one?
                  klass_name = types[0].to_s.downcase
                  article =
                    if klass_name[0] == "a"
      Severity: Minor
      Found in lib/cc/config/validation/hash_validations.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