skeptic 0.0.11 → 0.0.12
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.markdown +6 -0
- data/VERSION +1 -1
- data/lib/skeptic/rules/spaces_around_operators.rb +25 -6
- data/lib/skeptic/sexp_visitor.rb +3 -4
- data/skeptic.gemspec +4 -6
- metadata +3 -5
- data/e.rb +0 -10
- data/skeptic-0.0.9.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6e1fc6b21c5b3fa8b5ba3c556552cdcce8086ba
|
4
|
+
data.tar.gz: 31ce95b2d523a1043f8048b50f196a3e8beab10b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8eb3496b7e1e23ec3e8f7ec89a7b84e5de5bdf95f0f33a5f5eb1a24608e716381c9bf7b0343e5eb2265af64a021f2f98e07ed535f9418e273de34747e4228b29
|
7
|
+
data.tar.gz: acc962c666098071ead2296fa73f415b4fc62e6d9fd8a8f06544e2a9794a3f542ba5a698dabfaf50f93b54ba958891c22c9d47b4332d224549e2babc52b16ecd
|
data/CHANGELOG.md
CHANGED
data/README.markdown
CHANGED
@@ -34,8 +34,14 @@ Skeptic checks if the code complies to a number of rules and reports the violati
|
|
34
34
|
* **Line length** - line length does not exceed a certain number.
|
35
35
|
* **Lines per method** - methods are at most N lines long. Ignores empty lines and lines with `end`
|
36
36
|
* **Max nesting depth** - at most N levels of nesting. Blocks, conditions and loops are considered a level of nesting.
|
37
|
+
* **Methods per class** - the number of methods per class does not exceed a certain number
|
37
38
|
* **No semicolons** - stops you from using semicolons as expression delimiters.
|
38
39
|
* **No trailing whitespace** - points out if your lines end on whitespace.
|
40
|
+
* **Naming conventions** - checks if the names of variables/methods/classes follow the conventions
|
41
|
+
* **No global variables** - does not allow the use of global variables
|
42
|
+
* **Max method arity** - limits the arguments count per method
|
43
|
+
* **Spaces around operators** - checks for spaces around operators
|
44
|
+
* **English words for names** - detection of non-English words in names
|
39
45
|
|
40
46
|
## Copyright
|
41
47
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.12
|
@@ -7,6 +7,8 @@ module Skeptic
|
|
7
7
|
|
8
8
|
OPERATORS_WITHOUT_SPACES_AROUND_THEM = ['**', '::', '...', '..']
|
9
9
|
IGNORED_TOKEN_TYPES = [:on_sp, :on_ignored_nl, :on_nl, :on_lparen, :on_symbeg, :on_lbracket, :on_lbrace]
|
10
|
+
LEFT_LIMIT_TOKEN_TYPES = [:on_lparen, :on_lbracket]
|
11
|
+
RIGHT_LIMIT_TOKEN_TYPES = [:on_rparen, :on_rbracket]
|
10
12
|
|
11
13
|
def initialize(data)
|
12
14
|
@violations = []
|
@@ -19,8 +21,7 @@ module Skeptic
|
|
19
21
|
@violations = tokens.each_cons(3).select do |_, token, _|
|
20
22
|
operator_expecting_spaces? token
|
21
23
|
end.select do |left, operator, right|
|
22
|
-
|
23
|
-
no_spaces_on_right_of?(operator, right)
|
24
|
+
no_spaces_around? operator, left, right
|
24
25
|
end.map do |_, operator, _|
|
25
26
|
[operator.last, operator.first[0]]
|
26
27
|
end
|
@@ -44,20 +45,38 @@ module Skeptic
|
|
44
45
|
not OPERATORS_WITHOUT_SPACES_AROUND_THEM.include? token.last
|
45
46
|
end
|
46
47
|
|
48
|
+
def no_spaces_around?(operator, left, right)
|
49
|
+
if LEFT_LIMIT_TOKEN_TYPES.include?(left[1])
|
50
|
+
mark_special_tokens right.first
|
51
|
+
end
|
52
|
+
if range_operator?(left)
|
53
|
+
mark_special_tokens left.last
|
54
|
+
end
|
55
|
+
no_spaces_on_left_of?(operator, left) or
|
56
|
+
no_spaces_on_right_of?(operator, right)
|
57
|
+
end
|
58
|
+
|
47
59
|
def no_spaces_on_left_of?(operator, neighbour)
|
48
|
-
neighbour.first[0] == operator.first[0] and
|
49
|
-
!
|
60
|
+
neighbour.first[0] == operator.first[0] and
|
61
|
+
!LEFT_LIMIT_TOKEN_TYPES.include?(neighbour[1]) and
|
62
|
+
!range_operator?(neighbour) and
|
63
|
+
!special_token?(neighbour)
|
50
64
|
end
|
51
65
|
|
52
66
|
def no_spaces_on_right_of?(operator, neighbour)
|
53
|
-
neighbour.first[0] == operator.first[0] and
|
54
|
-
!
|
67
|
+
neighbour.first[0] == operator.first[0] and
|
68
|
+
!RIGHT_LIMIT_TOKEN_TYPES.include?(neighbour[1]) and
|
69
|
+
!special_token?(neighbour)
|
55
70
|
end
|
56
71
|
|
57
72
|
def whitespace_token?(token)
|
58
73
|
token[1] == :on_sp or token[1] == :on_ignored_nl
|
59
74
|
end
|
60
75
|
|
76
|
+
def range_operator?(operator)
|
77
|
+
operator.last[0..1] == '..'
|
78
|
+
end
|
79
|
+
|
61
80
|
def mark_special_tokens(*token_locations)
|
62
81
|
@special_tokens_locations.concat(token_locations)
|
63
82
|
end
|
data/lib/skeptic/sexp_visitor.rb
CHANGED
@@ -77,19 +77,18 @@ module Skeptic
|
|
77
77
|
|
78
78
|
def extract_param_idents(tree)
|
79
79
|
type, first, second = *tree
|
80
|
+
|
80
81
|
case type
|
81
82
|
when :params, :mlhs_add_star
|
82
|
-
tree[1..-1].
|
83
|
+
tree[1..-1].select { |e| e }.map { |node| extract_param_idents node }.reduce [], :+
|
83
84
|
when :mlhs_paren, :blockarg, :rest_param
|
84
85
|
extract_param_idents first
|
85
86
|
when :@ident, :@label
|
86
87
|
[tree]
|
87
88
|
when Symbol
|
88
89
|
[]
|
89
|
-
when nil, false
|
90
|
-
[]
|
91
90
|
else
|
92
|
-
tree.
|
91
|
+
tree.select { |e| e }.map { |node| extract_param_idents node }.reduce [], :+
|
93
92
|
end
|
94
93
|
end
|
95
94
|
end
|
data/skeptic.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
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.
|
5
|
+
# stub: skeptic 0.0.12 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "skeptic"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.12"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Stefan Kanev"]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2015-10-13"
|
15
15
|
s.description = "An experimental, half-assed, bug-ridden and highly opinionated code analyzer."
|
16
16
|
s.email = "stefan.kanev@gmail.com"
|
17
17
|
s.executables = ["skeptic"]
|
@@ -30,7 +30,6 @@ Gem::Specification.new do |s|
|
|
30
30
|
"Rakefile",
|
31
31
|
"VERSION",
|
32
32
|
"bin/skeptic",
|
33
|
-
"e.rb",
|
34
33
|
"features/skeptic.feature",
|
35
34
|
"lib/skeptic.rb",
|
36
35
|
"lib/skeptic/critic.rb",
|
@@ -51,12 +50,11 @@ Gem::Specification.new do |s|
|
|
51
50
|
"lib/skeptic/rules/spaces_around_operators.rb",
|
52
51
|
"lib/skeptic/scope.rb",
|
53
52
|
"lib/skeptic/sexp_visitor.rb",
|
54
|
-
"skeptic-0.0.9.gem",
|
55
53
|
"skeptic.gemspec"
|
56
54
|
]
|
57
55
|
s.homepage = "http://github.com/skanev/skeptic"
|
58
56
|
s.licenses = ["MIT"]
|
59
|
-
s.rubygems_version = "2.
|
57
|
+
s.rubygems_version = "2.4.8"
|
60
58
|
s.summary = "Skeptic points out annoying things in your code"
|
61
59
|
|
62
60
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skeptic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Kanev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trollop
|
@@ -141,7 +141,6 @@ files:
|
|
141
141
|
- Rakefile
|
142
142
|
- VERSION
|
143
143
|
- bin/skeptic
|
144
|
-
- e.rb
|
145
144
|
- features/skeptic.feature
|
146
145
|
- lib/skeptic.rb
|
147
146
|
- lib/skeptic/critic.rb
|
@@ -162,7 +161,6 @@ files:
|
|
162
161
|
- lib/skeptic/rules/spaces_around_operators.rb
|
163
162
|
- lib/skeptic/scope.rb
|
164
163
|
- lib/skeptic/sexp_visitor.rb
|
165
|
-
- skeptic-0.0.9.gem
|
166
164
|
- skeptic.gemspec
|
167
165
|
homepage: http://github.com/skanev/skeptic
|
168
166
|
licenses:
|
@@ -184,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
182
|
version: '0'
|
185
183
|
requirements: []
|
186
184
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.
|
185
|
+
rubygems_version: 2.4.8
|
188
186
|
signing_key:
|
189
187
|
specification_version: 4
|
190
188
|
summary: Skeptic points out annoying things in your code
|
data/e.rb
DELETED
data/skeptic-0.0.9.gem
DELETED
Binary file
|