Showing 2,376 of 2,376 total issues
Method shell_syntax
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def shell_syntax
[].tap do |cmd|
cmd.push "colocation #{@id} #{@score}:"
- 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 merge_operations
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def merge_operations(attrs)
if attrs.empty?
# No operations to set, get rid of the list (if it exists)
xml.elements['operations'].remove if xml.elements['operations']
else
- 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
File nodes.js
has 371 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Copyright (c) 2009-2015 Tim Serong <tserong@suse.com>
// See COPYING for license.
$(function() {
var rowStyleFn = function(row, index) {
File reports_controller.rb
has 371 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ReportsController < ApplicationController
before_action :login_required
before_action :set_title
before_action :set_record, only: [:show, :destroy, :download, :cache]
before_action :set_transition, only: [:display, :detail, :graph, :logs, :diff, :pefile, :status, :cib]
Method has too many lines. [57/30] Open
def persist!
writer = {
crm_config: {},
rsc_defaults: {},
op_defaults: {},
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for submit is too high. [42.68/15] Open
def submit
pa = JSON.parse(params[:pa]) if params[:pa]
pa = Rails.cache.read("#{session.id}-#{params[:id]}") if pa.nil?
if pa.nil?
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for sort_ops is too high. [42/15] Open
def sort_ops(a, b)
a_op = a.attributes['operation']
b_op = b.attributes['operation']
a_call_id = a.attributes['call-id'].to_i
b_call_id = b.attributes['call-id'].to_i
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Similar blocks of code found in 2 locations. Consider refactoring. Open
unhighlight: function(element, errorClass, validClass) {
if (element.type === "radio") {
this.findByName(element.name).removeClass(errorClass).addClass(validClass);
} else {
$(element)
- 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 131.
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
highlight: function(element, errorClass, validClass) {
if (element.type === "radio") {
this.findByName(element.name).addClass(errorClass).removeClass(validClass);
} else {
$(element)
- 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 131.
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
Assignment Branch Condition size for simple? is too high. [41.98/15] Open
def simple?
rules.none? ||
rules.length == 1 &&
rules[0][:expressions] &&
rules[0][:expressions].length == 1 &&
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for select is too high. [41.1/15] Open
def select(field, choices = nil, args = {}, html = {})
unless options.fetch(:bootstrap, true)
return super
end
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method persist!
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def persist!
writer = {
crm_config: {},
rsc_defaults: {},
op_defaults: {},
- 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 fix_clone_instances
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def fix_clone_instances(rsclist)
rsclist.each do |res|
if res[:clone_max]
# There'll be a stale default instance lying around if the resource was
# started before it was cloned (bnc#711180), so ditch it. This is all
- 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 has too many lines. [55/30] Open
def mapping
# TODO(must): Are other meta attributes for clone valid?
@mapping ||= begin
{
"is-managed" => {
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for merge_nvpairs is too high. [40.5/15] Open
def merge_nvpairs(list, attrs)
return if xml.nil?
if attrs.empty?
# No attributes to set, get rid of the list (if it exists)
xml.elements[list].remove if xml.elements[list]
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for merge_nvpairs is too high. [40.36/15] Open
def merge_nvpairs(list, attrs)
if attrs.empty?
# No attributes to set, get rid of the list (if it exists)
xml.elements[list].remove if xml.elements[list]
else
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for has_feature? is too high. [40.84/15] Open
def has_feature?(feature)
case feature
when :crm_history
Rails.cache.fetch(:has_crm_history) {
Util.safe_x('echo', 'quit', '|', '/usr/sbin/crm history', '2>&1')
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
File oplist.js
has 356 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Copyright (c) 2009-2015 Tim Serong <tserong@suse.com>
// See COPYING for license.
// ops and values is:
//
Method has too many lines. [54/30] Open
def instantiate(xml, state)
record = allocate
record.id = state[:id]
record.xml = xml
record.name = state[:name]
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for update_name is too high. [39.1/15] Open
def update_name
from = params[:id]
to = params[:to]
@source = params[:source] || "edit"
@resource = Resource.find from
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric