Showing 15 of 15 total issues
Class UniqueTestCaseTagger
has 60 methods (exceeds 20 allowed). Consider refactoring. Open
class UniqueTestCaseTagger
# The pattern of a sub id
SUB_ID_PATTERN = /^\d+\-\d+$/ # Not a part of the public API. Subject to change at any time.
File unique_test_case_tagger.rb
has 430 lines of code (exceeds 250 allowed). Consider refactoring. Open
module CukeCataloger
# A tagger that handles test case cataloging.
class UniqueTestCaseTagger
Method scan_for_tagged_tests
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def scan_for_tagged_tests(feature_directory, tag_prefix = '@test_case_', id_column_name = 'test_case_id')
@results = []
@known_id_tags = {}
configure_id_tag(tag_prefix)
- 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 create_tasks
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.create_tasks
desc 'Add unique id tags to tests in the given directory'
task 'tag_tests', [:directory, :prefix, :row_id, :id_column_name] do |_t, args|
location = args[:directory] || '.'
prefix = args[:prefix] || '@test_case_'
- 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 create_tasks
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create_tasks
desc 'Add unique id tags to tests in the given directory'
task 'tag_tests', [:directory, :prefix, :row_id, :id_column_name] do |_t, args|
location = args[:directory] || '.'
prefix = args[:prefix] || '@test_case_'
Method check_for_malformed_row_tags
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def check_for_malformed_row_tags(test, id_column_name)
test.examples.each do |example|
next unless id_column?(example, id_column_name)
example_rows_for(example).each do |row|
- 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 fill_in_row
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def fill_in_row(file_lines, line_index, row, row_id, id_column_name)
Method update_value_row
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def update_value_row(file_lines, line_index, row, row_id, id_column_name)
Method tag_tests
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def tag_tests(feature_directory, tag_prefix = '@test_case_', explicit_indexes = {}, tag_rows = true, id_column_name = 'test_case_id') # rubocop:disable Metrics/LineLength
Method validate_rows
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def validate_rows(test, rule, desired, row_check, id_column_name)
Method validate_rows
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_rows(test, rule, desired, row_check, id_column_name)
test.examples.each do |example|
next unless id_column?(example, id_column_name)
example_rows_for(example).each do |row|
- 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 determine_known_ids
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def determine_known_ids(feature_directory, tag_prefix = '@test_case_', id_column_name = 'test_case_id')
known_ids = []
found_tagged_objects = scan_for_tagged_tests(feature_directory, tag_prefix, id_column_name)
.collect { |result| result[:object] }
- 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 configure_test_suite_model
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def configure_test_suite_model(feature_directory)
@directory = CukeModeler::Directory.new(feature_directory)
@model_repo = CQL::Repository.new(@directory)
@tests = @model_repo.query do
- 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
When(/^the ids in the test suite are validated$/) do
@directory = CukeModeler::Directory.new(@test_directory)
args = [@directory.path]
args << @tag_prefix if @tag_prefix
- 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 25.
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
When(/^the existing ids are determined$/) do
@directory = CukeModeler::Directory.new(@test_directory)
args = [@directory.path]
args << @tag_prefix if @tag_prefix
- 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 25.
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