Enable Style/DoubleNegation Rubocop cop

This cop checks for uses of double negation (!!) to convert something to a boolean value. It doesn't support autocorrection, so all the offenses where manually solved.

Closes #1374
This commit is contained in:
Chaitanya 2017-03-20 19:12:40 +05:30
parent 56c7906d52
commit 7de009e46e
3 changed files with 7 additions and 8 deletions

View file

@ -122,6 +122,10 @@ Style/TrailingBlankLines:
Style/TrailingWhitespace: Style/TrailingWhitespace:
Enabled: true Enabled: true
# Checks for uses of double negation (!!) to convert something to a boolean value.
Style/DoubleNegation:
Enabled: true
AllCops: AllCops:
Include: Include:
- '**/Rakefile' - '**/Rakefile'

View file

@ -246,11 +246,6 @@ Style/Documentation:
Style/DotPosition: Style/DotPosition:
Enabled: false Enabled: false
# Offense count: 5
Style/DoubleNegation:
Exclude:
- 'app/models/conference.rb'
# Offense count: 1 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/ElseAlignment: Style/ElseAlignment:

View file

@ -838,7 +838,7 @@ class Conference < ActiveRecord::Base
# * +True+ -> If conference has a venue object. # * +True+ -> If conference has a venue object.
# * +False+ -> IF conference has no venue object. # * +False+ -> IF conference has no venue object.
def venue_set? def venue_set?
!!venue venue.present?
end end
## ##
@ -848,7 +848,7 @@ class Conference < ActiveRecord::Base
# * +True+ -> If conference has a cfp object. # * +True+ -> If conference has a cfp object.
# * +False+ -> If conference has no cfp object. # * +False+ -> If conference has no cfp object.
def cfp_set? def cfp_set?
!!program.cfp program.cfp.present?
end end
## ##
@ -858,7 +858,7 @@ class Conference < ActiveRecord::Base
# * +True+ -> If conference has a start and a end date. # * +True+ -> If conference has a start and a end date.
# * +False+ -> If conference has no start or end date. # * +False+ -> If conference has no start or end date.
def registration_date_set? def registration_date_set?
!!registration_period && !!registration_period.start_date && !!registration_period.end_date registration_period.present? && registration_period.start_date.present? && registration_period.end_date.present?
end end
# Calculates the distribution from events. # Calculates the distribution from events.