rubocop 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubocop might be problematic. Click here for more details.

@@ -177,4 +177,8 @@ AvoidPerlisms:
177
177
 
178
178
  # Avoid Perl-style regex back references.
179
179
  AvoidPerlBackrefs:
180
+ Enabled: true
181
+
182
+ # Avoid the use of class variables.
183
+ AvoidClassVars:
180
184
  Enabled: true
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
@@ -41,6 +41,7 @@ require 'rubocop/cop/collection_methods'
41
41
  require 'rubocop/cop/avoid_for'
42
42
  require 'rubocop/cop/avoid_perlisms'
43
43
  require 'rubocop/cop/avoid_perl_backrefs'
44
+ require 'rubocop/cop/avoid_class_vars'
44
45
 
45
46
  require 'rubocop/report/report'
46
47
  require 'rubocop/report/plain_text'
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ module Rubocop
4
+ module Cop
5
+ class AvoidClassVars < Cop
6
+ def inspect(file, source, tokens, sexp)
7
+ each(:@cvar, sexp) do |s|
8
+ class_var = s[1]
9
+ lineno = s[2].lineno
10
+
11
+ add_offence(
12
+ :convention,
13
+ lineno,
14
+ "Replace class var #{class_var} with a class instance var."
15
+ )
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Rubocop
4
- VERSION = '0.3.2'
4
+ VERSION = '0.4.2'
5
5
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "rubocop"
8
- s.version = "0.4.1"
8
+ s.version = "0.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bozhidar Batsov"]
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
34
34
  "lib/rubocop/cli.rb",
35
35
  "lib/rubocop/cop/align_parameters.rb",
36
36
  "lib/rubocop/cop/ampersands_pipes_vs_and_or.rb",
37
+ "lib/rubocop/cop/avoid_class_vars.rb",
37
38
  "lib/rubocop/cop/avoid_for.rb",
38
39
  "lib/rubocop/cop/avoid_perl_backrefs.rb",
39
40
  "lib/rubocop/cop/avoid_perlisms.rb",
@@ -75,6 +76,7 @@ Gem::Specification.new do |s|
75
76
  "spec/rubocop/cli_spec.rb",
76
77
  "spec/rubocop/cops/align_parameters_spec.rb",
77
78
  "spec/rubocop/cops/ampersands_pipes_vs_and_or_spec.rb",
79
+ "spec/rubocop/cops/avoid_class_vars_spec.rb",
78
80
  "spec/rubocop/cops/avoid_for_spec.rb",
79
81
  "spec/rubocop/cops/avoid_perl_backrefs_spec.rb",
80
82
  "spec/rubocop/cops/avoid_perlisms_spec.rb",
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ module Rubocop
6
+ module Cop
7
+ describe AvoidClassVars do
8
+ let(:acv) { AvoidClassVars.new }
9
+
10
+ it 'registers an offence for class variables' do
11
+ inspect_source(acv,
12
+ 'file.rb',
13
+ ['class TestClass; @@test = 10; end'])
14
+ expect(acv.offences.size).to eq(1)
15
+ expect(acv.offences.map(&:message))
16
+ .to eq(['Replace class var @@test with a class instance var.'])
17
+ end
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -149,6 +149,7 @@ files:
149
149
  - lib/rubocop/cli.rb
150
150
  - lib/rubocop/cop/align_parameters.rb
151
151
  - lib/rubocop/cop/ampersands_pipes_vs_and_or.rb
152
+ - lib/rubocop/cop/avoid_class_vars.rb
152
153
  - lib/rubocop/cop/avoid_for.rb
153
154
  - lib/rubocop/cop/avoid_perl_backrefs.rb
154
155
  - lib/rubocop/cop/avoid_perlisms.rb
@@ -190,6 +191,7 @@ files:
190
191
  - spec/rubocop/cli_spec.rb
191
192
  - spec/rubocop/cops/align_parameters_spec.rb
192
193
  - spec/rubocop/cops/ampersands_pipes_vs_and_or_spec.rb
194
+ - spec/rubocop/cops/avoid_class_vars_spec.rb
193
195
  - spec/rubocop/cops/avoid_for_spec.rb
194
196
  - spec/rubocop/cops/avoid_perl_backrefs_spec.rb
195
197
  - spec/rubocop/cops/avoid_perlisms_spec.rb
@@ -252,7 +254,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
252
254
  version: '0'
253
255
  segments:
254
256
  - 0
255
- hash: -395662942126839838
257
+ hash: 3258861329978794858
256
258
  required_rubygems_version: !ruby/object:Gem::Requirement
257
259
  none: false
258
260
  requirements: