pivotal/LicenseFinder

View on GitHub

Showing 62 of 62 total issues

File definitions.rb has 450 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module LicenseFinder
  class License
    module Definitions
      extend self

Severity: Minor
Found in lib/license_finder/license/definitions.rb - About 6 hrs to fix

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

      class Decisions
        ######
        # READ
        ######
    
    
    Severity: Minor
    Found in lib/license_finder/decisions.rb - About 5 hrs to fix

      Class Configuration has 40 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 5 hrs to fix

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

          class License
            module Definitions
              extend self
        
              def all
        Severity: Minor
        Found in lib/license_finder/license/definitions.rb - About 3 hrs to fix

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

            class Package
              attr_reader :logger, :name, :version, :authors, :summary, :description, :children, :parents, :groups, :manual_approval, :license_names_from_spec, :install_path
          
              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

            File decisions.rb has 261 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'open-uri'
            require 'license_finder/license'
            require 'license_finder/manual_licenses'
            
            module LicenseFinder
            Severity: Minor
            Found in lib/license_finder/decisions.rb - About 2 hrs to fix

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

                module CLI
                  class RestrictedLicenses < Base
                    extend Subcommand
                    include MakesDecisions
              
              
              Severity: Major
              Found in lib/license_finder/cli/restricted_licenses.rb and 1 other location - About 1 hr to fix
              lib/license_finder/cli/permitted_licenses.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 73.

              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 PermittedLicenses < Base
                    extend Subcommand
                    include MakesDecisions
              
              
              Severity: Major
              Found in lib/license_finder/cli/permitted_licenses.rb and 1 other location - About 1 hr to fix
              lib/license_finder/cli/restricted_licenses.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 73.

              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 prepare_command
                      stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(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 longest_common_paths has a Cognitive Complexity of 13 (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 prepare has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  def prepare
                    Dir.chdir(project_path) do
                      cmd = prepare_command
                      stdout, stderr, status = Cmd.run(cmd)
                      return if status.success?
              Severity: Minor
              Found in lib/license_finder/package_managers/nuget.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 36 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

                Method unassign_from_specific_versions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    def unassign_from_specific_versions(name, lic, versions)
                      return unless @specific_versions[name]
                
                      versions.each do |version|
                        if @specific_versions[name][version]
                Severity: Minor
                Found in lib/license_finder/manual_licenses.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 license_finder_config has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def license_finder_config
                        extract_options(
                          :project_path,
                          :decisions_file,
                          :enabled_package_managers,
                Severity: Minor
                Found in lib/license_finder/cli/base.rb - About 1 hr to fix

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

                      def current_packages
                        # the licenses plugin supports the classic production flag
                        cmd = "#{Yarn::SHELL_COMMAND}#{classic_yarn_production_flag}"
                        if yarn_version == 1
                          cmd += ' --no-progress'
                  Severity: Minor
                  Found in lib/license_finder/package_managers/yarn.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 supported_pnpm? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def supported_pnpm?
                        Dir.chdir(project_path) do
                          version_string, stderr_str, status = Cmd.run('pnpm --version')
                          raise "Command 'pnpm -v' failed to execute: #{stderr_str}" unless status.success?
                  
                  
                  Severity: Minor
                  Found in lib/license_finder/package_managers/pnpm.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

                  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 55.

                  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 55.

                  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 newbsd has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def newbsd
                          template = Template.named('NewBSD')
                          alternate_content = template.content.gsub(
                            'Neither the name of <organization> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.',
                            'The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission.'
                  Severity: Minor
                  Found in lib/license_finder/license/definitions.rb - About 1 hr to fix

                    Method all has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def all
                            [
                              agpl3,
                              apache1_1,
                              apache2,
                    Severity: Minor
                    Found in lib/license_finder/license/definitions.rb - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language