codeclimate/codeclimate-duplication

View on GitHub

Showing 95 of 95 total issues

OS Command Injection in Rake
Open

    rake (10.4.2)
Severity: Critical
Found in Gemfile.lock by bundler-audit

Advisory: CVE-2020-8130

Criticality: High

URL: https://github.com/advisories/GHSA-jppv-gw3r-w3q8

Solution: upgrade to >= 12.3.3

Race condition when using persistent connections
Open

    excon (0.57.1)
Severity: Minor
Found in Gemfile.lock by bundler-audit

Advisory: CVE-2019-16779

URL: https://github.com/excon/excon/security/advisories/GHSA-q58g-455p-8vw9

Solution: upgrade to >= 0.71.0

Class Base has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

      class Base
        RESCUABLE_ERRORS = [
          ::CC::Engine::Analyzers::ParserError,
          ::Errno::ENOENT,
          ::Racc::ParseError,
Severity: Minor
Found in lib/cc/engine/analyzers/analyzer_base.rb - About 2 hrs to fix

    Function cast_value has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def cast_value(value):
        if value is None or isinstance(value, (bool, string_type())):
            return value
        elif PY3 and isinstance(value, bytes):
            return value.decode()
    Severity: Minor
    Found in lib/cc/engine/analyzers/python/parser.py - 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 report has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def report
              flay.analyze.each do |issue|
                violations = new_violations(issue)
    
                violations.each do |violation|
    Severity: Minor
    Found in lib/cc/engine/analyzers/reporter.rb - About 45 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 flatter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def flatter
        result = dup.clear
        result.mass = mass
    
        each_with_object(result) do |s, r|
    Severity: Minor
    Found in lib/ccflay.rb - About 45 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(file)
              if (skip_reason = skip?(file))
                CC.logger.info("Skipping file #{file} because #{skip_reason}")
                nil
              else
    Severity: Minor
    Found in lib/cc/engine/analyzers/analyzer_base.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

    Avoid too many return statements within this function.
    Open

            return value
    Severity: Major
    Found in lib/cc/engine/analyzers/python/parser.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return to_json(value)
      Severity: Major
      Found in lib/cc/engine/analyzers/python/parser.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return [cast_value(v) for v in value]
        Severity: Major
        Found in lib/cc/engine/analyzers/python/parser.py - About 30 mins to fix

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

                  def files
                    engine_config.include_paths.flat_map do |path|
                      pathname = Pathname.new(path)
                      if pathname.directory? && !pathname.cleanpath.symlink?
                        expand(path)
          Severity: Minor
          Found in lib/cc/engine/analyzers/file_list.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

          Missing magic comment # frozen_string_literal: true.
          Open

          module CC
          Severity: Minor
          Found in lib/cc/engine/parse_metrics.rb by rubocop

          This cop is designed to help upgrade to 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 in 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: when_needed (default)

          # The `when_needed` style will add the frozen string literal comment
          # to files only when the `TargetRubyVersion` is set to 2.3+.
          # bad
          module Foo
            # ...
          end
          
          # good
          # frozen_string_literal: true
          
          module Foo
            # ...
          end

          Example: EnforcedStyle: always

          # The `always` style will always add the frozen string literal comment
          # to a file, regardless of the Ruby version or if `freeze` or `<

          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

          Do not freeze immutable objects, as freezing them has no effect.
          Open

                    REQUEST_PATH = "/javascript".freeze

          This cop check for uses of Object#freeze on immutable objects.

          Example:

          # bad
          CONST = 1.freeze
          
          # good
          CONST = 1

          Remove unnecessary require statement.
          Open

          require "thread"

          Checks for unnecessary require statement.

          The following features are unnecessary require statement because they are already loaded.

          ruby -ve 'p $LOADED_FEATURES.reject { |feature| %r|/| =~ feature }' ruby 2.2.8p477 (2017-09-14 revision 59906) [x86_64-darwin13] ["enumerator.so", "rational.so", "complex.so", "thread.rb"]

          This cop targets Ruby 2.2 or higher containing these 4 features.

          Example:

          # bad
          require 'unloaded_feature'
          require 'thread'
          
          # good
          require 'unloaded_feature'

          Do not freeze immutable objects, as freezing them has no effect.
          Open

                      "(EOL_COMMENT ___)".freeze,

          This cop check for uses of Object#freeze on immutable objects.

          Example:

          # bad
          CONST = 1.freeze
          
          # good
          CONST = 1

          Do not use empty case condition, instead use an if expression.
          Open

                    case

          This cop checks for case statements with an empty condition.

          Example:

          # bad:
          case
          when x == 0
            puts 'x is 0'
          when y == 0
            puts 'y is 0'
          else
            puts 'neither is 0'
          end
          
          # good:
          if x == 0
            puts 'x is 0'
          elsif y == 0
            puts 'y is 0'
          else
            puts 'neither is 0'
          end
          
          # good: (the case condition node is not empty)
          case n
          when 0
            puts 'zero'
          when 1
            puts 'one'
          else
            puts 'more'
          end

          Avoid comma after the last item of an array.
          Open

                    MINOR = "minor".freeze,

          This cop checks for trailing comma in array and hash literals.

          Example: EnforcedStyleForMultiline: consistent_comma

          # bad
          a = [1, 2,]
          
          # good
          a = [
            1, 2,
            3,
          ]
          
          # good
          a = [
            1,
            2,
          ]

          Example: EnforcedStyleForMultiline: comma

          # bad
          a = [1, 2,]
          
          # good
          a = [
            1,
            2,
          ]

          Example: EnforcedStyleForMultiline: no_comma (default)

          # bad
          a = [1, 2,]
          
          # good
          a = [
            1,
            2
          ]

          Avoid comma after the last item of a hash.
          Open

                    value: count,
          Severity: Minor
          Found in lib/cc/engine/parse_metrics.rb by rubocop

          This cop checks for trailing comma in array and hash literals.

          Example: EnforcedStyleForMultiline: consistent_comma

          # bad
          a = [1, 2,]
          
          # good
          a = [
            1, 2,
            3,
          ]
          
          # good
          a = [
            1,
            2,
          ]

          Example: EnforcedStyleForMultiline: comma

          # bad
          a = [1, 2,]
          
          # good
          a = [
            1,
            2,
          ]

          Example: EnforcedStyleForMultiline: no_comma (default)

          # bad
          a = [1, 2,]
          
          # good
          a = [
            1,
            2
          ]

          Avoid comma after the last item of an array.
          Open

                      "**/*.swift",

          This cop checks for trailing comma in array and hash literals.

          Example: EnforcedStyleForMultiline: consistent_comma

          # bad
          a = [1, 2,]
          
          # good
          a = [
            1, 2,
            3,
          ]
          
          # good
          a = [
            1,
            2,
          ]

          Example: EnforcedStyleForMultiline: comma

          # bad
          a = [1, 2,]
          
          # good
          a = [
            1,
            2,
          ]

          Example: EnforcedStyleForMultiline: no_comma (default)

          # bad
          a = [1, 2,]
          
          # good
          a = [
            1,
            2
          ]

          Do not freeze immutable objects, as freezing them has no effect.
          Open

                      "(NUKE ___)".freeze,

          This cop check for uses of Object#freeze on immutable objects.

          Example:

          # bad
          CONST = 1.freeze
          
          # good
          CONST = 1
          Severity
          Category
          Status
          Source
          Language