Showing 390 of 425 total issues
Avoid deeply nested control flow statements. Open
raise IllegalXpathError, 'attributes must be $NAMESPACE:$NAME' if tvalues.size != 2
Method update
has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring. Open
def update
authorize @package, :update?
@patchinfo = Patchinfo.new(patchinfo_params)
if @patchinfo.valid?
xml = @patchinfo.to_xml(@project, @package)
- 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
Avoid deeply nested control flow statements. Confirmed
elsif @last_key && @attribs[table][@last_key][:double]
@condition_values_needed.times { @condition_values << [value, value] }
else
@condition_values_needed.times { @condition_values << value }
Similar blocks of code found in 2 locations. Consider refactoring. Open
class RepoBuildStarted < Base
self.message_bus_routing_key = 'repo.build_started'
self.description = 'Repository (re)started building'
payload_keys :project, :repo, :arch, :buildid
- 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 40.
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 rpmlint_result
has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring. Confirmed
def rpmlint_result
@repo_arch_hash = {}
@buildresult = Buildresult.find_hashed(project: @project.to_param, package: @package.to_param, view: 'status')
repos = [] # Temp var
if @buildresult
- 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 build_query_from_hash
has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring. Open
def self.build_query_from_hash(hash, key_list = nil)
key_list ||= hash.keys
query = key_list.map do |key|
next unless hash.key?(key)
- 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
class RepoBuildFinished < Base
self.message_bus_routing_key = 'repo.build_finished'
self.description = 'Repository finished building'
payload_keys :project, :repo, :arch, :buildid
- 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 40.
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 show
has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring. Open
def show
# FIXME: Remove this statement when scmsync is fully supported
if @project.scmsync.present?
flash[:error] = "Package sources for project #{@project.name} are received through scmsync.
This is not yet fully supported by the OBS frontend"
- 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 involved_packages_and_projects
has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring. Open
def involved_packages_and_projects
involved_items = []
roles = roles_to_filter
involved_items.concat(involved_items_as_owner) if filter_by_owner?
- 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
Avoid deeply nested control flow statements. Open
if qtype == :predicate
parse_predicate(root, stack[0])
stack.shift
elsif qtype.nil? || qtype == :qname
# just a plain existence test
Method get_log_chunk
has 6 arguments (exceeds 5 allowed). Consider refactoring. Open
def get_log_chunk(project, package_name, repo, arch, start, theend)
Method log_chunk
has 6 arguments (exceeds 5 allowed). Consider refactoring. Open
def self.log_chunk(project_name, package_name, repository_name, architecture_name, starting_line, ending_line)
Method branch
has 6 arguments (exceeds 5 allowed). Consider refactoring. Open
def self.branch(target_project, target_package, source_project, source_package, user, options = {})
Method info
has 6 arguments (exceeds 5 allowed). Consider refactoring. Open
def self.info(method, host, port, path, response, start_time)
Method fileinfo_ext
has 6 arguments (exceeds 5 allowed). Consider refactoring. Open
def self.fileinfo_ext(project_name, package_name, repository, arch, filename, options = {})
Method raw_log_chunk
has 6 arguments (exceeds 5 allowed). Consider refactoring. Open
def raw_log_chunk(project, package_name, repo, arch, start, theend)
Method copy
has 6 arguments (exceeds 5 allowed). Consider refactoring. Open
def self.copy(target_project_name, target_package_name, source_project_name, source_package_name, user_login, options = {})
Method can_register?
has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring. Open
def self.can_register?
# No registering if LDAP is on
if CONFIG['ldap_mode'] == :on && !User.admin_session?
logger.debug 'Someone tried to register with "ldap_mode" turned on'
raise ErrRegisterSave, 'Sorry, new users can only sign up via LDAP'
- 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 cleanup_linking_repos
has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring. Open
def cleanup_linking_repos
# replace links to this project repositories with links to the "deleted" repository
find_repos(:linking_repositories) do |linking_repository|
linking_repository.path_elements.includes(:link).find_each do |path_element|
next unless path_element.link.db_project_id == id && path_element.repository.db_project_id != id
- 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_by_name
has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring. Open
def get_by_name(name, include_all_packages: false)
dbp = find_by_name(name, skip_check_access: true)
if dbp.nil?
dbp, remote_name = find_remote_project(name)
return "#{dbp.name}:#{remote_name}" if dbp
- 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"