skeptic 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c8d44e3011bf063dbd07ae0e073e78516f7d0fa
4
- data.tar.gz: 6a8bf2b2a6fdbfad9e0ec6171c85d51d7a63c81e
3
+ metadata.gz: b6e1fc6b21c5b3fa8b5ba3c556552cdcce8086ba
4
+ data.tar.gz: 31ce95b2d523a1043f8048b50f196a3e8beab10b
5
5
  SHA512:
6
- metadata.gz: 89d4f4062d23107211f796f5170d46c4d0a3c5b02ee1a0537c50dd3e8eeb78f3a1c40d3856c6eefa4f5033907a52256ab98814777c552c0d9eee41ef70cce702
7
- data.tar.gz: af0e4aed0d92d169417d603f8f152811b5656b56b1fab714cafdec12ba60048469feb6137361f1aada03b0bfdace17533d9d4aba7e1c2bb9e23178abea41b8b2
6
+ metadata.gz: 8eb3496b7e1e23ec3e8f7ec89a7b84e5de5bdf95f0f33a5f5eb1a24608e716381c9bf7b0343e5eb2265af64a021f2f98e07ed535f9418e273de34747e4228b29
7
+ data.tar.gz: acc962c666098071ead2296fa73f415b4fc62e6d9fd8a8f06544e2a9794a3f542ba5a698dabfaf50f93b54ba958891c22c9d47b4332d224549e2babc52b16ecd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.12 (2015-10-14)
2
+ Bugfixes:
3
+ - Fix range operators handling and stop detecting splat operators in beginning of collection literals
4
+
1
5
  ## 0.0.11 (2014-10-27)
2
6
  Bugfixes:
3
7
  - Fix issue with using mixed parameter types ([s2gatev](https://github.com/s2gatev))
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.11
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
- no_spaces_on_left_of?(operator, left) or
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 neighbour[1] != :on_lparen and
49
- !special_token? neighbour
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 neighbour[1] != :on_rparen and
54
- !special_token? neighbour
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
@@ -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].compact.map { |node| extract_param_idents node }.reduce [], :+
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.compact.map { |node| extract_param_idents node }.reduce [], :+
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.11 ruby lib
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.11"
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 = "2014-10-27"
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.2.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.11
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: 2014-10-27 00:00:00.000000000 Z
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.2.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
@@ -1,10 +0,0 @@
1
- def e
2
- w(&b.d.f.e)
3
- end
4
-
5
- class Proc
6
- def ssdfe
7
- 2
8
- end
9
- end
10
-
data/skeptic-0.0.9.gem DELETED
Binary file