Showing 220 of 220 total issues
Class has too many lines. [149/100] Open
class Base
attr_reader :selected_position
# @param options [Hash|Array] collection of options to choose from
# @param flash_message [String] A message to be displayed above the downup menu
- Read upRead up
- Exclude checks
This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for print_simple_hash_options is too high. [28.07/15] Open
def print_simple_hash_options
options.each_with_index do |option_array, index|
if index == selected_position
stdout.puts "(#{eval("selector.#{selected_color}")}) " +
eval("option_array.last.#{selected_color}")
- 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 has too many lines. [18/10] Open
def prompt(position = 0)
@selected_position = position_selector(position)
colonel.system("clear")
header_proc.call
print_flash
- 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 execute_selection is too high. [22.36/15] Open
def execute_selection(input)
case options
when Array
options[selected_position]
when Hash
- 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 has too many lines. [16/10] Open
def execute_selection(input)
case options
when Array
options[selected_position]
when Hash
- 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 print_complex_hash_options is too high. [21.12/15] Open
def print_complex_hash_options
options.each_with_index do |option_array, index|
key = option_array.first
value_hash = option_array.last
if index == selected_position
- 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 prompt is too high. [19.1/15] Open
def prompt(position = 0)
@selected_position = position_selector(position)
colonel.system("clear")
header_proc.call
print_flash
- 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 has too many lines. [13/10] Open
def initialize(options:,
flash_message: nil,
flash_color: :green,
default_color: :brown,
selected_color: :magenta,
- 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.
Method has too many lines. [13/10] Open
def print_complex_hash_options
options.each_with_index do |option_array, index|
key = option_array.first
value_hash = option_array.last
if index == selected_position
- 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.
Method has too many lines. [12/10] Open
def process_input(input)
case input
when "\e[A", "k"
prompt(selected_position - 1)
when "\e[B", "j"
- 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 process_input is too high. [17.09/15] Open
def process_input(input)
case input
when "\e[A", "k"
prompt(selected_position - 1)
when "\e[B", "j"
- 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 has too many lines. [12/10] Open
def print_simple_hash_options
options.each_with_index do |option_array, index|
if index == selected_position
stdout.puts "(#{eval("selector.#{selected_color}")}) " +
eval("option_array.last.#{selected_color}")
- 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 read_char is too high. [16.55/15] Open
def read_char
stdin.echo = false
stdin.raw!
input = stdin.getc.chr
if input == "\e" then
- 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
Cyclomatic complexity for process_input is too high. [7/6] Open
def process_input(input)
case input
when "\e[A", "k"
prompt(selected_position - 1)
when "\e[B", "j"
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Method has too many lines. [11/10] Open
def read_char
stdin.echo = false
stdin.raw!
input = stdin.getc.chr
if input == "\e" then
- 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.
Method has too many lines. [11/10] Open
def initialize(options:,
selected_position: 0,
default_color: :brown,
selected_color: :magenta,
selector: "‣",
- 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.
Avoid parameter lists longer than 5 parameters. [11/5] Open
def initialize(options:,
flash_message: nil,
flash_color: :green,
default_color: :brown,
selected_color: :magenta,
- Read upRead up
- Exclude checks
This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.
Avoid parameter lists longer than 5 parameters. [10/5] Open
def initialize(options:,
selected_position: 0,
default_color: :brown,
selected_color: :magenta,
selector: "‣",
- Read upRead up
- Exclude checks
This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.
Identical blocks of code found in 2 locations. Consider refactoring. Open
def options_has_value_and_display?
options.values.all? { |option|
option.is_a?(Hash) && option.has_key?("value")
} && options.values.all? { |option|
option.is_a?(Hash) && option.has_key?("display")
- 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 27.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
def options_has_value_and_display?
options.values.all? { |option|
option.is_a?(Hash) && option.has_key?("value")
} && options.values.all? { |option|
option.is_a?(Hash) && option.has_key?("display")
- 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 27.
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