skeptic 0.0.12 → 0.0.14

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: b6e1fc6b21c5b3fa8b5ba3c556552cdcce8086ba
4
- data.tar.gz: 31ce95b2d523a1043f8048b50f196a3e8beab10b
3
+ metadata.gz: c50ddb8500c67652b5d76236fed471b66e7c10a2
4
+ data.tar.gz: 701c0cfc317879fcb8d23834dcaffab02ba5d7a7
5
5
  SHA512:
6
- metadata.gz: 8eb3496b7e1e23ec3e8f7ec89a7b84e5de5bdf95f0f33a5f5eb1a24608e716381c9bf7b0343e5eb2265af64a021f2f98e07ed535f9418e273de34747e4228b29
7
- data.tar.gz: acc962c666098071ead2296fa73f415b4fc62e6d9fd8a8f06544e2a9794a3f542ba5a698dabfaf50f93b54ba958891c22c9d47b4332d224549e2babc52b16ecd
6
+ metadata.gz: 3af0a80ff4d84495ae3cbe21163bb368913494a69a172d0027fa616e391a9e442170aa10e58e8c195a43ecc2a63fc2ec4b209af7694e95ca77e9e5292d69ce93
7
+ data.tar.gz: d459748904f7e8fd71e199318f93065cd352a723955cf15912dfbfa291c4e0a77166b5d04da53c5718b6e526a8dfa3cc4e26f9ebee3dfaf29f0a80dfbd46a9c5
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.12
1
+ 0.0.14
@@ -9,15 +9,19 @@ module Skeptic
9
9
  IGNORED_TOKEN_TYPES = [:on_sp, :on_ignored_nl, :on_nl, :on_lparen, :on_symbeg, :on_lbracket, :on_lbrace]
10
10
  LEFT_LIMIT_TOKEN_TYPES = [:on_lparen, :on_lbracket]
11
11
  RIGHT_LIMIT_TOKEN_TYPES = [:on_rparen, :on_rbracket]
12
+ WHITESPACE_TOKEN_TYPES = [:on_sp, :on_nl, :on_ignored_nl]
12
13
 
13
14
  def initialize(data)
14
15
  @violations = []
15
16
  @special_tokens_locations = []
17
+ @unary_token_locations = []
16
18
  end
17
19
 
18
20
  def apply_to(code, tokens, sexp)
19
21
  visit sexp
20
22
 
23
+ mark_unary tokens
24
+
21
25
  @violations = tokens.each_cons(3).select do |_, token, _|
22
26
  operator_expecting_spaces? token
23
27
  end.select do |left, operator, right|
@@ -46,6 +50,8 @@ module Skeptic
46
50
  end
47
51
 
48
52
  def no_spaces_around?(operator, left, right)
53
+ return false if unary_operator?(operator)
54
+
49
55
  if LEFT_LIMIT_TOKEN_TYPES.include?(left[1])
50
56
  mark_special_tokens right.first
51
57
  end
@@ -69,10 +75,6 @@ module Skeptic
69
75
  !special_token?(neighbour)
70
76
  end
71
77
 
72
- def whitespace_token?(token)
73
- token[1] == :on_sp or token[1] == :on_ignored_nl
74
- end
75
-
76
78
  def range_operator?(operator)
77
79
  operator.last[0..1] == '..'
78
80
  end
@@ -86,6 +88,25 @@ module Skeptic
86
88
  @special_tokens_locations.include? token.first
87
89
  end
88
90
 
91
+ def unary_operator?(token)
92
+ token[1] == :on_op and @unary_token_locations.include?(token[0])
93
+ end
94
+
95
+ def mark_unary(tokens)
96
+ @unary_token_locations = []
97
+ last_significant_token = nil
98
+ tokens.each do |token|
99
+ if token[1] == :on_op
100
+ if last_significant_token == :on_op
101
+ @unary_token_locations << token[0]
102
+ end
103
+ last_significant_token = :on_op
104
+ elsif !WHITESPACE_TOKEN_TYPES.include?(token[1])
105
+ last_significant_token = token[1]
106
+ end
107
+ end
108
+ end
109
+
89
110
  on :blockarg, :rest_param do |ident|
90
111
  mark_special_tokens ident.last
91
112
  end
@@ -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.12 ruby lib
5
+ # stub: skeptic 0.0.14 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "skeptic"
9
- s.version = "0.0.12"
9
+ s.version = "0.0.14"
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 = "2015-10-13"
14
+ s.date = "2015-10-16"
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"]
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.12
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Kanev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-13 00:00:00.000000000 Z
11
+ date: 2015-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trollop