pivotal/LicenseFinder

View on GitHub

Showing 45 of 61 total issues

Method options has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def options # rubocop:disable Metrics/AbcSize
      {
        logger: logger,
        project_path: config.project_path,
        log_directory: File.join(config.log_directory, project_name),
Severity: Minor
Found in lib/license_finder/core.rb - About 1 hr to fix

    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] = package_for_dependency(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

      Method get_yarn_packages has a Cognitive Complexity of 9 (exceeds 5 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 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

      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 parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def parse(info)
              @lines = info.lines.map(&:chomp)
              @state = :project_level # state of the state machine
              @projects = [] # list of projects
              @current_project = nil # current project being populated in the SM
        Severity: Minor
        Found in lib/license_finder/package_utils/conan_info_parser_v2.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 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 definition has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def definition(name, version)
                response = request("https://pypi.org/pypi/#{name}/#{version}/json")
                response.is_a?(Net::HTTPSuccess) ? JSON.parse(response.body).fetch('info', {}) : {}
              rescue *CONNECTION_ERRORS => e
                raise e, "Unable to read package from pypi.org #{name} #{version}: #{e}" unless @prepare_no_fail
        Severity: Minor
        Found in lib/license_finder/package_utils/pypi.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 author_names has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def author_names
              names = []
              if @json['author'].is_a?(Array)
                # "author":["foo","bar"] isn't valid according to the NPM package.json schema, but can be found in the wild.
                names += @json['author'].map { |a| author_name(a) }
        Severity: Minor
        Found in lib/license_finder/packages/npm_package.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 conda_search_info has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def conda_search_info(list_entry)
              command = 'conda search --info --json '
              command += "--channel #{list_entry['channel']} " if list_entry['channel'] && !list_entry['channel'].empty?
              command += "'#{list_entry['name']} #{list_entry['version']}'"
        
        
        Severity: Minor
        Found in lib/license_finder/package_managers/conda.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 current_packages_with_relations has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def current_packages_with_relations
              begin
                packages = current_packages
              rescue StandardError => e
                raise e unless @prepare_no_fail
        Severity: Minor
        Found in lib/license_finder/package_manager.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 current_packages has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def current_packages
              install_command = 'conan install .'
              Dir.chdir(project_path) { Cmd.run(install_command) }
        
              deps = deps_list(project_path)
        Severity: Minor
        Found in lib/license_finder/package_managers/conan.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

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

            def conda_list
              command = 'conda list'
              stdout, stderr, status = activated_conda(command)
        
              if status.success?
        Severity: Minor
        Found in lib/license_finder/package_managers/conda.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

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

            def self.restore(persisted, result = new)
              return result unless persisted
        
              # From https://makandracards.com/makandra/465149-ruby-the-yaml-safe_load-method-hides-some-pitfalls
              actions = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1')
        Severity: Minor
        Found in lib/license_finder/decisions.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

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

            def approval_of(name, version = nil)
              if !@approvals.key?(name)
                nil
              elsif !version.nil?
                @approvals[name] if @approvals[name][:safe_versions].empty? || @approvals[name][:safe_versions].include?(version)
        Severity: Minor
        Found in lib/license_finder/decisions.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

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

            def parse(info)
              @lines = info.lines.map(&:chomp)
              @state = :project_level # state of the state machine
              @projects = [] # list of projects
              @current_project = nil # current project being populated in the SM
        Severity: Minor
        Found in lib/license_finder/package_utils/conan_info_parser.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

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

              def say_each(coll)
                if coll.any?
                  coll.each do |item|
                    printer.say(block_given? ? yield(item) : item)
                  end
        Severity: Minor
        Found in lib/license_finder/cli/base.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

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

              def add(name, license, version)
                modifying do
                  decisions
                    .add_package(name, version, txn)
                    .license(name, license, txn)
        Severity: Minor
        Found in lib/license_finder/cli/dependencies.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

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

              def populate_groups(package_json)
                package_json.groups.each do |group|
                  group.package_names.each do |package_name|
                    @packages.each_key do |identifier|
                      next unless identifier.name == package_name
        Severity: Minor
        Found in lib/license_finder/packages/npm_package.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

        Severity
        Category
        Status
        Source
        Language