pivotal/LicenseFinder

View on GitHub

Showing 29 of 29 total issues

Class Decisions has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Decisions
    ######
    # READ
    ######

Severity: Minor
Found in lib/license_finder/decisions.rb - About 3 hrs to fix

    Class Configuration has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Configuration
        def self.with_optional_saved_config(primary_config)
          project_path = Pathname(primary_config.fetch(:project_path, Pathname.pwd)).expand_path
          config_file =  project_path.join('config', 'license_finder.yml')
          saved_config = config_file.exist? ? YAML.safe_load(config_file.read) : {}
    Severity: Minor
    Found in lib/license_finder/configuration.rb - About 3 hrs to fix

      Class Package has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Package
          attr_reader :logger
      
          def self.license_names_from_standard_spec(spec)
            licenses = spec['licenses'] || [spec['license']].compact
      Severity: Minor
      Found in lib/license_finder/package.rb - About 2 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          module CLI
            class Blacklist < Base
              extend Subcommand
              include MakesDecisions
        
        
        Severity: Major
        Found in lib/license_finder/cli/blacklist.rb and 1 other location - About 1 hr to fix
        lib/license_finder/cli/whitelist.rb on lines 4..28

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 70.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          module CLI
            class Whitelist < Base
              extend Subcommand
              include MakesDecisions
        
        
        Severity: Major
        Found in lib/license_finder/cli/whitelist.rb and 1 other location - About 1 hr to fix
        lib/license_finder/cli/blacklist.rb on lines 4..28

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 70.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

            def prepare
              if self.class.prepare_command
                stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(self.class.prepare_command) }
                unless status.success?
                  log_errors stderr
        Severity: Minor
        Found in lib/license_finder/package_manager.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 shared_options has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def self.shared_options
                method_option :debug,
                              aliases: '-d',
                              type: :boolean,
                              desc: 'Emit detailed info about what LicenseFinder is doing'
        Severity: Minor
        Found in lib/license_finder/cli/main.rb - About 1 hr to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            module CLI
              class IgnoredDependencies < Base
                extend Subcommand
                include MakesDecisions
          
          
          Severity: Major
          Found in lib/license_finder/cli/ignored_dependencies.rb and 1 other location - About 1 hr to fix
          lib/license_finder/cli/ignored_groups.rb on lines 4..28

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 52.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            module CLI
              class IgnoredGroups < Base
                extend Subcommand
                include MakesDecisions
          
          
          Severity: Major
          Found in lib/license_finder/cli/ignored_groups.rb and 1 other location - About 1 hr to fix
          lib/license_finder/cli/ignored_dependencies.rb on lines 4..28

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 52.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Method action_items has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def action_items
                  finder = LicenseAggregator.new(config, aggregate_paths)
                  any_packages = finder.any_packages?
                  unapproved = finder.unapproved
                  blacklisted = finder.blacklisted
          Severity: Minor
          Found in lib/license_finder/cli/main.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 longest_common_paths has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.longest_common_paths(paths)
              [].tap do |common_paths|
                # organize by matching root paths
                paths_with_roots = paths.group_by { |path| path.split('/').first }
                paths_with_roots.each do |common_root, full_paths|
          Severity: Minor
          Found in lib/license_finder/shared_helpers/common_path.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 packages_from_output has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def packages_from_output(output, path)
                package_lines = output.split("\n")
                packages_by_sha = {}
                package_lines.each do |p|
                  package_path, sha, repo = p.split
          Severity: Minor
          Found in lib/license_finder/package_managers/gvt.rb - About 1 hr to fix

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

                  def flattened_dependencies(npm_json, existing_packages = {})
                    identifier = Identifier.from_hash npm_json
                    if existing_packages[identifier].nil?
                      existing_packages[identifier] = NpmPackage.new(npm_json) if identifier
                      npm_json.fetch('dependencies', {}).values.map do |d|
            Severity: Minor
            Found in lib/license_finder/packages/npm_package.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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              class MavenPackage < Package
                def initialize(spec, options = {})
                  name = spec['artifactId']
                  name = "#{spec['groupId']}:#{name}" if options[:include_groups]
            
            
            Severity: Minor
            Found in lib/license_finder/packages/maven_package.rb and 1 other location - About 55 mins to fix
            lib/license_finder/packages/sbt_package.rb on lines 4..19

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 45.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                def current_packages
                  cmd = "#{Yarn::SHELL_COMMAND}#{production_flag}"
                  suffix = " --cwd #{project_path}" unless project_path.nil?
                  cmd += suffix unless suffix.nil?
            
            
            Severity: Minor
            Found in lib/license_finder/package_managers/yarn.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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              class SbtPackage < Package
                def initialize(spec, options = {})
                  name = spec['artifactId']
                  name = "#{spec['groupId']}:#{name}" if options[:include_groups]
            
            
            Severity: Minor
            Found in lib/license_finder/packages/sbt_package.rb and 1 other location - About 55 mins to fix
            lib/license_finder/packages/maven_package.rb on lines 4..19

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 45.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Method aggregate_paths has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def aggregate_paths
                    check_valid_project_path
                    aggregate_paths = config.aggregate_paths
                    project_path = config.project_path || Pathname.pwd
                    aggregate_paths = ProjectFinder.new(project_path, config.strict_matching).find_projects if config.recursive
            Severity: Minor
            Found in lib/license_finder/cli/main.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def initialize(name, version, license_text, url, options = {})
            Severity: Minor
            Found in lib/license_finder/packages/conan_package.rb - About 35 mins to fix

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

                  def go_list
                    Dir.chdir(project_path) do
                      # avoid checking canonical import path. some projects uses
                      # non-canonical import path and rely on the fact that the deps are
                      # checked in. Canonical paths are only checked by `go get'. We
              Severity: Minor
              Found in lib/license_finder/package_managers/go_15vendorexperiment.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 packages_lines has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def packages_lines(stdout)
                    packages_lines, last_package_lines =
                      stdout
                      .each_line
                      .map(&:strip)
              Severity: Minor
              Found in lib/license_finder/package_managers/mix.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

              Severity
              Category
              Status
              Source
              Language