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 [cast_value(v) for v in 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

          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

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

                    REQUEST_PATH = "/kotlin".freeze

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

          Example:

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

          Do not prefix writer method names with set_.
          Open

                  def set_default_line(default)
          Severity: Minor
          Found in lib/cc/engine/analyzers/node.rb by rubocop

          This cop makes sure that accessor methods are named properly.

          Example:

          # bad
          def set_attribute(value)
          end
          
          # good
          def attribute=(value)
          end
          
          # bad
          def get_attribute
          end
          
          # good
          def attribute
          end

          Prefer do...end over {...} for procedural blocks.
          Open

                    CC.logger.debug { "Contents:\n#{processed_source.raw_source}" }

          Check for uses of braces or do/end around single line or multi-line blocks.

          Example: EnforcedStyle: linecountbased (default)

          # bad - single line block
          items.each do |item| item / 5 end
          
          # good - single line block
          items.each { |item| item / 5 }
          
          # bad - multi-line block
          things.map { |thing|
            something = thing.some_method
            process(something)
          }
          
          # good - multi-line block
          things.map do |thing|
            something = thing.some_method
            process(something)
          end

          Example: EnforcedStyle: semantic

          # Prefer `do...end` over `{...}` for procedural blocks.
          
          # return value is used/assigned
          # bad
          foo = map do |x|
            x
          end
          puts (map do |x|
            x
          end)
          
          # return value is not used out of scope
          # good
          map do |x|
            x
          end
          
          # Prefer `{...}` over `do...end` for functional blocks.
          
          # return value is not used out of scope
          # bad
          each { |x|
            x
          }
          
          # return value is used/assigned
          # good
          foo = map { |x|
            x
          }
          map { |x|
            x
          }.inspect

          Example: EnforcedStyle: bracesforchaining

          # bad
          words.each do |word|
            word.flip.flop
          end.join("-")
          
          # good
          words.each { |word|
            word.flip.flop
          }.join("-")

          Avoid comma after the last item of a hash.
          Open

                  "swift"      => ::CC::Engine::Analyzers::Swift::Main,
          Severity: Minor
          Found in lib/cc/engine/duplication.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

                      "(comments ___)",
          Severity: Minor
          Found in lib/cc/engine/analyzers/go/main.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 rescuing the Exception class. Perhaps you meant to rescue StandardError?
          Open

                      rescue Exception => ex
                        CC.logger.warn("Error processing file: #{file}")
                        raise ex
          Severity: Minor
          Found in lib/cc/engine/analyzers/reporter.rb by rubocop

          This cop checks for rescue blocks targeting the Exception class.

          Example:

          # bad
          
          begin
            do_something
          rescue Exception
            handle_exception
          end

          Example:

          # good
          
          begin
            do_something
          rescue ArgumentError
            handle_exception
          end

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

                      "(VariableDeclarator _ (init (CallExpression (_ (Identifier require)) ___)))".freeze,

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

          Example:

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

          Avoid comma after the last item of an array.
          Open

                      "**/*.tsx",

          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 rescuing without specifying an error class.
          Open

                  rescue => ex

          This cop checks for rescuing StandardError. There are two supported styles implicit and explicit. This cop will not register an offense if any error other than StandardError is specified.

          Example: EnforcedStyle: implicit

          # `implicit` will enforce using `rescue` instead of
          # `rescue StandardError`.
          
          # bad
          begin
            foo
          rescue StandardError
            bar
          end
          
          # good
          begin
            foo
          rescue
            bar
          end
          
          # good
          begin
            foo
          rescue OtherError
            bar
          end
          
          # good
          begin
            foo
          rescue StandardError, SecurityError
            bar
          end

          Example: EnforcedStyle: explicit (default)

          # `explicit` will enforce using `rescue StandardError`
          # instead of `rescue`.
          
          # bad
          begin
            foo
          rescue
            bar
          end
          
          # good
          begin
            foo
          rescue StandardError
            bar
          end
          
          # good
          begin
            foo
          rescue OtherError
            bar
          end
          
          # good
          begin
            foo
          rescue StandardError, SecurityError
            bar
          end
          Severity
          Category
          Status
          Source
          Language