expertiza/expertiza

View on GitHub
spec/models/late_policy_spec.rb

Summary

Maintainability
A
3 hrs
Test Coverage

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

describe LatePolicy do
  let(:late_policy) { build(:late_policy) }
  let(:calculated_penalty) { build(:calculated_penalty) }
  let(:participant) { build(:participant) }
  let(:assignment_due_date) { build(:assignment_due_date) }
Severity: Minor
Found in spec/models/late_policy_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. [48/25]
Open

  describe 'validations' do
    it 'validates presence of policy_name' do
      late_policy.policy_name = ''
      expect(late_policy).not_to be_valid
    end
Severity: Minor
Found in spec/models/late_policy_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 3 locations. Consider refactoring.
Open

  describe '#check_update_calculated_penalty_points' do
    it 'updates calculated penalty by review penalty when deadline type id is 2' do
      calculated_penalty.deadline_type_id = 2
      allow(CalculatedPenalty).to receive(:all).and_return(Array(calculated_penalty))
      allow_any_instance_of(PenaltyHelper).to receive(:calculate_penalty).and_return(submission: 1, review: 2, meta_review: 3)
Severity: Major
Found in spec/models/late_policy_spec.rb and 2 other locations - About 1 hr to fix
spec/models/late_policy_spec.rb on lines 92..99
spec/models/late_policy_spec.rb on lines 116..123

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

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 3 locations. Consider refactoring.
Open

  describe '#check_update_calculated_penalty_points' do
    it 'updates calculated penalty by meta review penalty when deadline type id is 5' do
      calculated_penalty.deadline_type_id = 5
      allow(CalculatedPenalty).to receive(:all).and_return(Array(calculated_penalty))
      allow_any_instance_of(PenaltyHelper).to receive(:calculate_penalty).and_return(submission: 1, review: 2, meta_review: 3)
Severity: Major
Found in spec/models/late_policy_spec.rb and 2 other locations - About 1 hr to fix
spec/models/late_policy_spec.rb on lines 92..99
spec/models/late_policy_spec.rb on lines 104..111

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

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 3 locations. Consider refactoring.
Open

  describe '#check_update_calculated_penalty_points' do
    it 'updates calculated penalty by submission penalty when deadline type id is 1' do
      calculated_penalty.deadline_type_id = 1
      allow(CalculatedPenalty).to receive(:all).and_return(Array(calculated_penalty))
      allow_any_instance_of(PenaltyHelper).to receive(:calculate_penalty).and_return(submission: 1, review: 2, meta_review: 3)
Severity: Major
Found in spec/models/late_policy_spec.rb and 2 other locations - About 1 hr to fix
spec/models/late_policy_spec.rb on lines 104..111
spec/models/late_policy_spec.rb on lines 116..123

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

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

include is used at the top level. Use inside class or module.
Open

include PenaltyHelper
Severity: Minor
Found in spec/models/late_policy_spec.rb by rubocop

This cop checks that include, extend and prepend exists at the top level. Using these at the top level affects the behavior of Object. There will not be using include, extend and prepend at the top level. Let's use it inside class or module.

Example:

# bad
include M

class C
end

# bad
extend M

class C
end

# bad
prepend M

class C
end

# good
class C
  include M
end

# good
class C
  extend M
end

# good
class C
  prepend M
end

(...) interpreted as grouped expression.
Open

  let (:response) { build(:response) }
Severity: Minor
Found in spec/models/late_policy_spec.rb by rubocop

Checks for space between the name of a called method and a left parenthesis.

Example:

# bad

puts (x + y)

Example:

# good

puts(x + y)

There are no issues that match your filters.

Category
Status