Skip to content

Commit

Permalink
[Fix #5601] Improve the description of Style/ClassVars
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatsov committed Apr 16, 2018
1 parent 3649fb5 commit ed013be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions lib/rubocop/cop/style/class_vars.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ module Style
# are signaled only on assignment to class variables to
# reduce the number of offenses that would be reported.
#
# Setting value for class variable need to take care.
# If some class has been inherited by other classes, setting value
# for class variable affected children classes.
# So using class instance variable is better in almost case.
# You have to be careful when setting a value for a class
# variable; if a class has been inherited, changing the
# value of a class variable also affects the inheriting
# classes. This means that it's almost always better to
# use a class instance variable instead.
#
# @example
# # bad
Expand Down
9 changes: 5 additions & 4 deletions manual/cops_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,11 @@ This cop checks for uses of class variables. Offenses
are signaled only on assignment to class variables to
reduce the number of offenses that would be reported.

Setting value for class variable need to take care.
If some class has been inherited by other classes, setting value
for class variable affected children classes.
So using class instance variable is better in almost case.
You have to be careful when setting a value for a class
variable; if a class has been inherited, changing the
value of a class variable also affects the inheriting
classes. This means that it's almost always better to
use a class instance variable instead.

### Examples

Expand Down

0 comments on commit ed013be

Please sign in to comment.