skeptic 0.0.6 → 0.0.7
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.
- checksums.yaml +7 -0
- data/VERSION +1 -1
- data/lib/skeptic/rules/naming_conventions.rb +6 -2
- data/lib/skeptic/rules/spaces_around_operators.rb +70 -5
- data/skeptic.gemspec +4 -3
- metadata +25 -46
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c134d0e254360008e27fa9cb86c40c93db1927f4
|
4
|
+
data.tar.gz: 4740e1bf1ad5a49988947f4271cc02670c02e8ec
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 15a38c21b6827006b04201c4cb85df642e9d23d222df9ae576e6de2bd7fa22f25c65eeb263e648a75e5c47d2fb3f65ead2d0209c6cb7435f2c097468b61372b0
|
7
|
+
data.tar.gz: 18a09be7c9be915270ec24fea66cfe12d705083147afc6ab8984fc4749d43daf4ca7cbbefa6cf45a93702b333214fc6f7bd180a7cd61c3102f074b36173aca62
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
@@ -12,6 +12,7 @@ module Skeptic
|
|
12
12
|
defs: :snake_case,
|
13
13
|
symbol: :snake_case,
|
14
14
|
:@ident => :snake_case,
|
15
|
+
:@gvar => :snake_case,
|
15
16
|
:@ivar => :snake_case,
|
16
17
|
:@cvar => :snake_case,
|
17
18
|
:@const => :screaming_snake_case
|
@@ -36,6 +37,7 @@ module Skeptic
|
|
36
37
|
def: 'method',
|
37
38
|
defs: 'method',
|
38
39
|
:@ident => 'local variable',
|
40
|
+
:@gvar => 'global variable',
|
39
41
|
:@ivar => 'instance variable',
|
40
42
|
:@cvar => 'class variable',
|
41
43
|
:@const => 'constant'
|
@@ -86,7 +88,7 @@ module Skeptic
|
|
86
88
|
|
87
89
|
on :assign do |target, value|
|
88
90
|
if target.first == :var_field
|
89
|
-
|
91
|
+
check_ident target.last.first, target
|
90
92
|
end
|
91
93
|
end
|
92
94
|
|
@@ -101,7 +103,9 @@ module Skeptic
|
|
101
103
|
end
|
102
104
|
|
103
105
|
def check_ident(type, ident)
|
104
|
-
|
106
|
+
if EXPECTED_CONVENTIONS.key? type
|
107
|
+
check_name(type, extract_name(ident), extract_line_number(ident))
|
108
|
+
end
|
105
109
|
end
|
106
110
|
|
107
111
|
def check_name(type, name, line)
|
@@ -3,18 +3,24 @@ module Skeptic
|
|
3
3
|
class SpacesAroundOperators
|
4
4
|
DESCRIPTION = 'Check for spaces around operators'
|
5
5
|
|
6
|
-
|
6
|
+
include SexpVisitor
|
7
|
+
|
8
|
+
OPERATORS_WITHOUT_SPACES_AROUND_THEM = ['**', '::', '...', '..']
|
9
|
+
IGNORED_TOKEN_TYPES = [:on_sp, :on_ignored_nl, :on_nl, :on_lparen, :on_symbeg]
|
7
10
|
|
8
11
|
def initialize(data)
|
9
12
|
@violations = []
|
13
|
+
@special_tokens_locations = []
|
10
14
|
end
|
11
15
|
|
12
16
|
def apply_to(code, tokens, sexp)
|
17
|
+
visit sexp
|
18
|
+
|
13
19
|
@violations = tokens.each_cons(3).select do |_, token, _|
|
14
20
|
operator_expecting_spaces? token
|
15
21
|
end.select do |left, operator, right|
|
16
|
-
|
17
|
-
|
22
|
+
no_spaces_on_left_of?(operator, left) or
|
23
|
+
no_spaces_on_right_of?(operator, right)
|
18
24
|
end.map do |_, operator, _|
|
19
25
|
[operator.last, operator.first[0]]
|
20
26
|
end
|
@@ -38,8 +44,67 @@ module Skeptic
|
|
38
44
|
not OPERATORS_WITHOUT_SPACES_AROUND_THEM.include? token.last
|
39
45
|
end
|
40
46
|
|
41
|
-
def
|
42
|
-
neighbour.first[0] == operator.first[0] and neighbour[1] != :
|
47
|
+
def no_spaces_on_left_of?(operator, neighbour)
|
48
|
+
neighbour.first[0] == operator.first[0] and neighbour[1] != :on_lparen and
|
49
|
+
!special_token? neighbour
|
50
|
+
end
|
51
|
+
|
52
|
+
def no_spaces_on_right_of?(operator, neighbour)
|
53
|
+
neighbour.first[0] == operator.first[0] and neighbour[1] != :on_rparen and
|
54
|
+
!special_token? neighbour
|
55
|
+
end
|
56
|
+
|
57
|
+
def whitespace_token?(token)
|
58
|
+
token[1] == :on_sp or token[1] == :on_ignored_nl
|
59
|
+
end
|
60
|
+
|
61
|
+
def mark_special_tokens(*token_locations)
|
62
|
+
@special_tokens_locations.concat(token_locations)
|
63
|
+
end
|
64
|
+
|
65
|
+
def special_token?(token)
|
66
|
+
IGNORED_TOKEN_TYPES.include? token[1] or
|
67
|
+
@special_tokens_locations.include? token.first
|
68
|
+
end
|
69
|
+
|
70
|
+
on :blockarg, :rest_param do |ident|
|
71
|
+
mark_special_tokens ident.last
|
72
|
+
end
|
73
|
+
|
74
|
+
on :args_add_block do |args, block|
|
75
|
+
visit args
|
76
|
+
if block
|
77
|
+
case block.first
|
78
|
+
when :symbol_literal, :dyna_symbol
|
79
|
+
sexp_location = block.last.last.last
|
80
|
+
symbol_location = [sexp_location[0], sexp_location[1] - 1]
|
81
|
+
mark_special_tokens symbol_location
|
82
|
+
when :vcall, :var_ref
|
83
|
+
mark_special_tokens block.last.last
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
on :mlhs_add_star, :args_add_star do |_, ident|
|
89
|
+
if ident.first == :var_ref or ident.first == :vcall
|
90
|
+
mark_special_tokens ident.last.last
|
91
|
+
else
|
92
|
+
mark_special_tokens ident.last
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
on :block_var do |params|
|
97
|
+
normal_params = params[1]
|
98
|
+
unless normal_params.empty?
|
99
|
+
right_param = normal_params.last
|
100
|
+
right_location = [right_param.last[0],
|
101
|
+
right_param.last[1] ]
|
102
|
+
mark_special_tokens normal_params.first.last, normal_params.last.last
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
on :unary do |_, token|
|
107
|
+
mark_special_tokens token.last
|
43
108
|
end
|
44
109
|
end
|
45
110
|
end
|
data/skeptic.gemspec
CHANGED
@@ -2,10 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: skeptic 0.0.7 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "skeptic"
|
8
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.7"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
12
|
s.authors = ["Stefan Kanev"]
|
@@ -52,11 +53,11 @@ Gem::Specification.new do |s|
|
|
52
53
|
s.homepage = "http://github.com/skanev/skeptic"
|
53
54
|
s.licenses = ["MIT"]
|
54
55
|
s.require_paths = ["lib"]
|
55
|
-
s.rubygems_version = "1.
|
56
|
+
s.rubygems_version = "2.1.5"
|
56
57
|
s.summary = "Skeptic points out annoying things in your code"
|
57
58
|
|
58
59
|
if s.respond_to? :specification_version then
|
59
|
-
s.specification_version =
|
60
|
+
s.specification_version = 4
|
60
61
|
|
61
62
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
62
63
|
s.add_runtime_dependency(%q<trollop>, [">= 1.16.2"])
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skeptic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Stefan Kanev
|
@@ -14,129 +13,113 @@ dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: trollop
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 1.16.2
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 1.16.2
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: ffi-aspell
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: cucumber
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: aruba
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - ">="
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - ">="
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: bundler
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - ">="
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - ">="
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: jeweler
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - ">="
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: simplecov
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - ">="
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '0'
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- -
|
122
|
+
- - ">="
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: '0'
|
142
125
|
description: An experimental, half-assed, bug-ridden and highly opinionated code analyzer.
|
@@ -148,9 +131,9 @@ extra_rdoc_files:
|
|
148
131
|
- LICENSE.txt
|
149
132
|
- README.markdown
|
150
133
|
files:
|
151
|
-
- .document
|
152
|
-
- .rspec
|
153
|
-
- .rvmrc
|
134
|
+
- ".document"
|
135
|
+
- ".rspec"
|
136
|
+
- ".rvmrc"
|
154
137
|
- CHANGELOG.md
|
155
138
|
- Gemfile
|
156
139
|
- LICENSE.txt
|
@@ -181,29 +164,25 @@ files:
|
|
181
164
|
homepage: http://github.com/skanev/skeptic
|
182
165
|
licenses:
|
183
166
|
- MIT
|
167
|
+
metadata: {}
|
184
168
|
post_install_message:
|
185
169
|
rdoc_options: []
|
186
170
|
require_paths:
|
187
171
|
- lib
|
188
172
|
required_ruby_version: !ruby/object:Gem::Requirement
|
189
|
-
none: false
|
190
173
|
requirements:
|
191
|
-
- -
|
174
|
+
- - ">="
|
192
175
|
- !ruby/object:Gem::Version
|
193
176
|
version: '0'
|
194
|
-
segments:
|
195
|
-
- 0
|
196
|
-
hash: -418497778918983562
|
197
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
|
-
none: false
|
199
178
|
requirements:
|
200
|
-
- -
|
179
|
+
- - ">="
|
201
180
|
- !ruby/object:Gem::Version
|
202
181
|
version: '0'
|
203
182
|
requirements: []
|
204
183
|
rubyforge_project:
|
205
|
-
rubygems_version: 1.
|
184
|
+
rubygems_version: 2.1.5
|
206
185
|
signing_key:
|
207
|
-
specification_version:
|
186
|
+
specification_version: 4
|
208
187
|
summary: Skeptic points out annoying things in your code
|
209
188
|
test_files: []
|