pivotal/LicenseFinder

View on GitHub

Showing 45 of 61 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

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

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

                      Method get_yarn_packages has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def get_yarn_packages(json_objects)
                            packages = []
                            incompatible_packages = []
                            json_objects.each do |json_object|
                              license = json_object['value']
                      Severity: Minor
                      Found in lib/license_finder/package_managers/yarn.rb - About 1 hr to fix

                        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
                                restricted = finder.restricted
                        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 current_packages has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def current_packages
                              # check if the minimum version of PNPM is met
                              raise 'The minimum PNPM version is not met, requires 7.17.0 or later' unless supported_pnpm?
                        
                              # check if the project directory has workspace file
                        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

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

                            def current_packages
                              unless File.exist?('pubspec.lock')
                                raise PubError, "No checked-out Pub packages found.
                                  Please install your dependencies first."
                              end
                        Severity: Minor
                        Found in lib/license_finder/package_managers/pub.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

                        Severity
                        Category
                        Status
                        Source
                        Language