expertiza/expertiza

View on GitHub
spec/models/criterion_spec.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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

describe 'criterion' do
  let(:questionnaire) { Questionnaire.new min_question_score: 0, max_question_score: 5 }
  let(:criterion) { Criterion.new id: 1, type: 'Criterion', seq: 1.0, txt: 'test txt', weight: 1, questionnaire: questionnaire }
  let(:answer_no_comments) { Answer.new answer: 8 }
  let(:answer_comments) { Answer.new answer: 3, comments: 'text comments' }
Severity: Minor
Found in spec/models/criterion_spec.rb by rubocop

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.

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

  describe '#complete' do
    it 'returns the html without answer and no dropdown or scale' do
      html = criterion.complete(0, nil, 0, 5).to_s
      expect(html).to eq('<div><label for="responses_0">test txt</label></div>')
    end
Severity: Minor
Found in spec/models/criterion_spec.rb by rubocop

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

  describe '#dropdown_criterion_question' do
    it 'returns the html without answer' do
      html = criterion.dropdown_criterion_question(0, nil, 0, 5).to_s
      expect(html).to eq("<div><select id=\"responses_0_score\" name=\"responses[0][score]\" class=\"review-rating\" ><option value = ''>--</option><option value=0>0</option><option value=1>1</option><option value=2>2</option><option value=3>3</option><option value=4>4</option><option value=5>5</option></select></div><br><br><textarea id=\"responses_0_comments\" name=\"responses[0][comment]\" class=\"tinymce\"></textarea></td>")
    end
Severity: Major
Found in spec/models/criterion_spec.rb and 1 other location - About 1 hr to fix
spec/models/criterion_spec.rb on lines 75..88

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

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

  describe '#scale_criterion_question' do
    it 'returns the html without answer' do
      html = criterion.scale_criterion_question(0, nil, 0, 5).to_s
      expect(html).to eq('<input id="responses_0_score" name="responses[0][score]" type="hidden"><table><tr><td width="10%"></td><td width="10%"><label>0</label></td><td width="10%"><label>1</label></td><td width="10%"><label>2</label></td><td width="10%"><label>3</label></td><td width="10%"><label>4</label></td><td width="10%"><label>5</label></td><td width="10%"></td></tr><tr><td width="10%"></td><td width="10%"><input type="radio" id="0" value="0" name="Radio_1"checked="checked"></td><td width="10%"><input type="radio" id="1" value="1" name="Radio_1"></td><td width="10%"><input type="radio" id="2" value="2" name="Radio_1"></td><td width="10%"><input type="radio" id="3" value="3" name="Radio_1"></td><td width="10%"><input type="radio" id="4" value="4" name="Radio_1"></td><td width="10%"><input type="radio" id="5" value="5" name="Radio_1"></td><script>jQuery("input[name=Radio_1]:radio").change(function() {var response_score = jQuery("#responses_0_score");var checked_value = jQuery("input[name=Radio_1]:checked").val();response_score.val(checked_value);});</script><td width="10%"></td><td width="10%"></td></tr></table><textarea cols=70 rows=1 id="responses_0_comments" name="responses[0][comment]" class="tinymce"></textarea>')
    end
Severity: Major
Found in spec/models/criterion_spec.rb and 1 other location - About 1 hr to fix
spec/models/criterion_spec.rb on lines 58..71

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

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

Useless assignment to variable - dropdown_or_scale.
Open

      html = criterion.complete(0, nil, 0, 5, dropdown_or_scale = 'dropdown').to_s
Severity: Minor
Found in spec/models/criterion_spec.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Useless assignment to variable - dropdown_or_scale.
Open

      html = criterion.complete(0, answer_no_comments, 0, 5, dropdown_or_scale = 'dropdown').to_s
Severity: Minor
Found in spec/models/criterion_spec.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Useless assignment to variable - dropdown_or_scale.
Open

      html = criterion.complete(0, answer_no_comments, 0, 5, dropdown_or_scale = 'scale').to_s
Severity: Minor
Found in spec/models/criterion_spec.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Useless assignment to variable - dropdown_or_scale.
Open

      html = criterion.complete(0, answer_comments, 0, 5, dropdown_or_scale = 'scale').to_s
Severity: Minor
Found in spec/models/criterion_spec.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Useless assignment to variable - dropdown_or_scale.
Open

      html = criterion.complete(0, answer_comments, 0, 5, dropdown_or_scale = 'dropdown').to_s
Severity: Minor
Found in spec/models/criterion_spec.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Useless assignment to variable - dropdown_or_scale.
Open

      html = criterion.complete(0, nil, 0, 5, dropdown_or_scale = 'scale').to_s
Severity: Minor
Found in spec/models/criterion_spec.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

There are no issues that match your filters.

Category
Status