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
Class Decisions
has 41 methods (exceeds 20 allowed). Consider refactoring. Open
class Decisions
######
# READ
######
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) : {}
Class License
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class License
module Definitions
extend self
def all
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
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
module CLI
class RestrictedLicenses < Base
extend Subcommand
include MakesDecisions
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
module CLI
class PermittedLicenses < Base
extend Subcommand
include MakesDecisions
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- Read upRead up
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|
- Read upRead up
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?
- Read upRead up
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'
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]
- Read upRead up
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,
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'
- Read upRead up
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?
- Read upRead up
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
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
module CLI
class IgnoredGroups < Base
extend Subcommand
include MakesDecisions
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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.'
Method all
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def all
[
agpl3,
apache1_1,
apache2,