expertiza/expertiza

View on GitHub
spec/models/airbrake_expection_errors_unit_tests_spec.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Block has too many lines. [38/25]
Open

describe 'Airbrake-1781551925379466692' do
  let(:assignment) { build(:assignment, id: 1) }
  let(:assignment_questionaire1) { build(:assignment_questionaire1, assignment_id: 1, used_in_round: 2) }
  let(:assignment_due_date) do
    build(:assignment_due_date, parent_id: 1, due_at: '2011-11-11 11:11:11 UTC', deadline_name: 'Review',

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  it 'can deal with comment is not nil, with one comments greater than 10' do
    # @list_of_rows = [VmQuestionResponseRow.new('', 1, 1, 5, 0)]
    allow(Answer).to receive(:where).with(any_args)
                                    .and_return([double('Answer', question_id: 1, response_id: 1, comments: 'one two three four five six seven eight nine ten eleven'),
                                                 double('Answer', question_id: 1, response_id: 1, comments: '233')])
Severity: Major
Found in spec/models/airbrake_expection_errors_unit_tests_spec.rb and 1 other location - About 1 hr to fix
spec/models/airbrake_expection_errors_unit_tests_spec.rb on lines 28..35

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 65.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  it 'can deal with comment is not nil, with two comments greater than 10' do
    allow(Answer).to receive(:where).with(any_args)
                                    .and_return([double('Answer', question_id: 1, response_id: 1, comments: 'one two three four five six seven eight nine ten eleven'),
                                                 double('Answer', question_id: 1, response_id: 1, comments: 'one two three four five six seven eight nine ten eleven')])
    expect { @return_value = @qs.number_of_comments_greater_than_10_words }.not_to raise_error(NoMethodError)
Severity: Major
Found in spec/models/airbrake_expection_errors_unit_tests_spec.rb and 1 other location - About 1 hr to fix
spec/models/airbrake_expection_errors_unit_tests_spec.rb on lines 17..25

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 65.

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

Further Reading

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

    expect(@qs.instance_variable_get(:@list_of_rows)[0].metric_hash["> 10 Word Comments"]).to eq(2)

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

    expect(@qs.instance_variable_get(:@list_of_rows)[0].metric_hash["> 10 Word Comments"]).to eq(1)

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

    expect(@qs.instance_variable_get(:@list_of_rows)[0].metric_hash["> 10 Word Comments"]).to eq(0)

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

There are no issues that match your filters.

Category
Status