excellent 1.7.1 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +7 -0
- data/VERSION.yml +3 -3
- data/lib/simplabs/excellent.rb +1 -1
- data/lib/simplabs/excellent/checks/global_variable_check.rb +3 -1
- data/lib/simplabs/excellent/checks/method_name_check.rb +2 -1
- data/lib/simplabs/excellent/checks/name_check.rb +6 -2
- data/lib/simplabs/excellent/checks/rails/custom_initialize_method_check.rb +1 -1
- data/lib/simplabs/excellent/parsing/class_context.rb +1 -1
- data/lib/simplabs/excellent/parsing/conditional_context.rb +1 -1
- data/lib/simplabs/excellent/parsing/cvar_context.rb +6 -2
- data/lib/simplabs/excellent/parsing/gvar_context.rb +8 -0
- data/lib/simplabs/excellent/parsing/resbody_context.rb +6 -0
- metadata +48 -62
data/History.txt
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
=======
|
2
|
+
= 1.7.2
|
3
|
+
|
4
|
+
* fixed Simplabs::Excellent::Checks::Rails::CustomInitializeMethodCheck
|
5
|
+
* fixed Simplabs::Excellent::Checks::MethodNameCheck so it allows method names that exist in Ruby itself
|
6
|
+
* fixed Simplabs::Excellent::Checks::GlobalVariableCheck so it doesn't report false positives for rescue bodies
|
7
|
+
|
2
8
|
= 1.7.1
|
3
9
|
|
4
10
|
* fixed excellent for Ruby 2.0
|
5
11
|
* some internal cleanup
|
12
|
+
* support -v switch on command line
|
6
13
|
|
7
14
|
= 1.7.0
|
8
15
|
|
data/VERSION.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
---
|
1
|
+
---
|
2
2
|
:major: 1
|
3
|
-
:minor:
|
4
|
-
:patch:
|
3
|
+
:minor: 7
|
4
|
+
:patch: 2
|
data/lib/simplabs/excellent.rb
CHANGED
@@ -21,7 +21,9 @@ module Simplabs
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def evaluate(context) #:nodoc:
|
24
|
-
|
24
|
+
if context.is_a?(Parsing::GasgnContext) || !context.reassigned_local_exception_var?
|
25
|
+
add_warning(context, 'Global variable {{variable}} used.', { :variable => context.full_name })
|
26
|
+
end
|
25
27
|
end
|
26
28
|
|
27
29
|
end
|
@@ -17,10 +17,11 @@ module Simplabs
|
|
17
17
|
class MethodNameCheck < NameCheck
|
18
18
|
|
19
19
|
DEFAULT_PATTERN = /^[_a-z<>=\[|+-\/\*\~\%\&`\|\^]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/
|
20
|
+
WHITELIST = %w([] ! != !~ % & * ** + +@ - -@ / < << <= <=> == === =~ > >= >> ^ ` | ~)
|
20
21
|
|
21
22
|
def initialize(options = {}) #:nodoc:
|
22
23
|
pattern = options['pattern'] || DEFAULT_PATTERN
|
23
|
-
super([Parsing::MethodContext, Parsing::SingletonMethodContext], pattern)
|
24
|
+
super([Parsing::MethodContext, Parsing::SingletonMethodContext], pattern, WHITELIST)
|
24
25
|
end
|
25
26
|
|
26
27
|
protected
|
@@ -8,14 +8,18 @@ module Simplabs
|
|
8
8
|
|
9
9
|
class NameCheck < Base #:nodoc:
|
10
10
|
|
11
|
-
def initialize(interesting_contexts, pattern)
|
11
|
+
def initialize(interesting_contexts, pattern, whitelist = [])
|
12
12
|
super()
|
13
13
|
@interesting_contexts = interesting_contexts
|
14
14
|
@pattern = pattern
|
15
|
+
@whitelist = whitelist
|
15
16
|
end
|
16
17
|
|
17
18
|
def evaluate(context)
|
18
|
-
|
19
|
+
name = context.name.to_s
|
20
|
+
if !@whitelist.include?(name) && !(name =~ @pattern)
|
21
|
+
add_warning(*warning_args(context))
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
end
|
@@ -23,7 +23,7 @@ module Simplabs
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def evaluate(context) #:nodoc:
|
26
|
-
add_warning(context, '{{class}} defines initialize method.', { :class => context.full_name }) if context.active_record_model? &&
|
26
|
+
add_warning(context, '{{class}} defines initialize method.', { :class => context.full_name }) if context.active_record_model? && context.defines_initializer?
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
@@ -12,7 +12,7 @@ module Simplabs
|
|
12
12
|
|
13
13
|
def contains_parameter?
|
14
14
|
return false unless @parent.is_a?(MethodContext)
|
15
|
-
return @exp[1][1] if @exp[1][0] == :lvar and @parent.has_parameter?(@exp[1][1])
|
15
|
+
return @exp[1][1] if !!@exp[1] && @exp[1][0] == :lvar and @parent.has_parameter?(@exp[1][1])
|
16
16
|
false
|
17
17
|
end
|
18
18
|
|
@@ -15,8 +15,12 @@ module Simplabs
|
|
15
15
|
return @name if !@parent
|
16
16
|
full_name = @name
|
17
17
|
parent = @parent
|
18
|
-
parent
|
19
|
-
|
18
|
+
parent = parent.parent until parent.is_a?(ClassContext) || parent.is_a?(ModuleContext) rescue nil
|
19
|
+
if !!parent
|
20
|
+
"#{parent.full_name}.#{full_name}"
|
21
|
+
else
|
22
|
+
full_name
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
26
|
end
|
@@ -12,6 +12,14 @@ module Simplabs
|
|
12
12
|
@full_name = @name
|
13
13
|
end
|
14
14
|
|
15
|
+
def reassigned_local_exception_var?
|
16
|
+
if self.parent.is_a?(Simplabs::Excellent::Parsing::ResbodyContext)
|
17
|
+
@name == '!' && self.parent.assigns_exception_to_local_variable?.inspect
|
18
|
+
else
|
19
|
+
false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
15
23
|
end
|
16
24
|
|
17
25
|
end
|
metadata
CHANGED
@@ -1,61 +1,55 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: excellent
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.7.2
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 7
|
9
|
-
- 1
|
10
|
-
version: 1.7.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Marco Otte-Witte
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2009-08-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: ruby_parser
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 3
|
31
|
-
- 0
|
32
|
-
version: "3.0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.0'
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: sexp_processor
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: sexp_processor
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
39
33
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 4
|
46
|
-
- 0
|
47
|
-
version: "4.0"
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '4.0'
|
48
38
|
type: :runtime
|
49
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '4.0'
|
50
46
|
description:
|
51
47
|
email: marco.otte-witte@simplabs.com
|
52
|
-
executables:
|
48
|
+
executables:
|
53
49
|
- excellent
|
54
50
|
extensions: []
|
55
|
-
|
56
51
|
extra_rdoc_files: []
|
57
|
-
|
58
|
-
files:
|
52
|
+
files:
|
59
53
|
- History.txt
|
60
54
|
- README.rdoc
|
61
55
|
- VERSION.yml
|
@@ -164,37 +158,29 @@ files:
|
|
164
158
|
- spec/spec_helper.rb
|
165
159
|
homepage: http://github.com/simplabs/excellent
|
166
160
|
licenses: []
|
167
|
-
|
168
161
|
post_install_message:
|
169
|
-
rdoc_options:
|
162
|
+
rdoc_options:
|
170
163
|
- --inline-source
|
171
164
|
- --charset=UTF-8
|
172
|
-
require_paths:
|
165
|
+
require_paths:
|
173
166
|
- lib
|
174
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
175
168
|
none: false
|
176
|
-
requirements:
|
177
|
-
- -
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
|
180
|
-
|
181
|
-
- 0
|
182
|
-
version: "0"
|
183
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ! '>='
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
174
|
none: false
|
185
|
-
requirements:
|
186
|
-
- -
|
187
|
-
- !ruby/object:Gem::Version
|
188
|
-
|
189
|
-
segments:
|
190
|
-
- 0
|
191
|
-
version: "0"
|
175
|
+
requirements:
|
176
|
+
- - ! '>='
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
192
179
|
requirements: []
|
193
|
-
|
194
180
|
rubyforge_project:
|
195
|
-
rubygems_version: 1.8.
|
181
|
+
rubygems_version: 1.8.23
|
196
182
|
signing_key:
|
197
183
|
specification_version: 2
|
198
184
|
summary: Source Code analysis gem for Ruby and Rails
|
199
185
|
test_files: []
|
200
|
-
|
186
|
+
has_rdoc: true
|