Showing 31 of 31 total issues
Method parser_pom
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def parser_pom(pom_url, pom_str)
LicenseAuto.logger.debug("pom_str:\n#{pom_str[0..70]}")
doc = Nokogiri::XML(pom_str).remove_namespaces!
# Source Code Manager
- 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 parser_pom
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parser_pom(pom_url, pom_str)
LicenseAuto.logger.debug("pom_str:\n#{pom_str[0..70]}")
doc = Nokogiri::XML(pom_str).remove_namespaces!
# Source Code Manager
Method get_license_info
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def get_license_info()
possible_ref = @ref || match_versioned_ref
LicenseAuto.logger.debug("possible_ref: #{possible_ref}")
# If possible_ref is nil, the Github API server will return the default branch contents
contents = @server.repos.contents.get(path: '/', ref: possible_ref)
- 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 get_license_info
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_license_info()
possible_ref = @ref || match_versioned_ref
LicenseAuto.logger.debug("possible_ref: #{possible_ref}")
# If possible_ref is nil, the Github API server will return the default branch contents
contents = @server.repos.contents.get(path: '/', ref: possible_ref)
Method get_license_info
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_license_info()
if @package.version.nil?
begin
@package.version = chose_latest_available_version('*')
rescue Exception => e
Method parse_dependencies
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def parse_dependencies
# gemfiles = dependency_file_path_names(pattern=gemfile_pattern)
# definition = ::Bundler::Definition.build(gemfiles.first, nil, nil)
# definition.dependencies.each {|dep|
- 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 parse_dependencies
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def parse_dependencies
package_json_files = dependency_file_path_names
if package_json_files.empty?
LicenseAuto.logger.info("#{LANGUAGE}: #{dependency_file_pattern} file not exist")
- 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 parse_dependencies
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_dependencies
package_json_files = dependency_file_path_names
if package_json_files.empty?
LicenseAuto.logger.info("#{LANGUAGE}: #{dependency_file_pattern} file not exist")
Method chose_package_server
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def chose_package_server()
begin
@server =
if self.language == 'Golang' and self.server
matcher = Matcher::SourceURL.new(self.server)
- 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 get_license_info
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def get_license_info()
if @package.version.nil?
begin
@package.version = chose_latest_available_version('*')
rescue Exception => e
- 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 parse_dependencies
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_dependencies
# gemfiles = dependency_file_path_names(pattern=gemfile_pattern)
# definition = ::Bundler::Definition.build(gemfiles.first, nil, nil)
# definition.dependencies.each {|dep|
Method get_license_info
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_license_info()
if @package.version.nil?
begin
@package.version = get_latest_version['number']
rescue Exception => e
Method get_license_info
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_license_info()
license_info = LicenseAuto::LicenseInfoWrapper.new
query_set = select
if query_set.nil?
- 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 chose_package_server
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def chose_package_server()
begin
@server =
if self.language == 'Golang' and self.server
matcher = Matcher::SourceURL.new(self.server)
Method list_dependencies
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def list_dependencies
if resolve_dependencies
deps = Set.new
Dir.chdir(@path) do
cmd = 'mvn dependency:list -T 4 -DincludeScope=runtime'
- 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 get_license_info
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_license_info()
if @package.version.nil?
begin
@package.version = get_latest_version['number']
rescue Exception => e
- 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 list_dependencies
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def list_dependencies(project_name=nil)
Dir.chdir(@path) do
deps = Set.new
cmd = if project_name
"gradle -q #{project_name}:dependencies --configuration runtime"
- 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 parse_dependencies
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_dependencies
contents = list_contents
if contents.nil?
LicenseAuto.logger.info("Golang dependencies not exist")
return []
Similar blocks of code found in 2 locations. Consider refactoring. Open
def self.check_cli
bash_cmd = "go version"
# LicenseAuto.logger.debug(bash_cmd)
stdout_str, stderr_str, _status = Open3.capture3(bash_cmd)
golang_version = /1\.[456]/
- 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 48.
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
def self.check_cli
bash_cmd = "bower -version"
# LicenseAuto.logger.debug(bash_cmd)
stdout_str, stderr_str, _status = Open3.capture3(bash_cmd)
bower_version = /1\./
- 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 48.
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