stylr 0.0.13 → 0.0.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b6c5c561144b3451f609f05fa568125170b5e10
4
- data.tar.gz: f6ddc8e22a2febd98984ebefef01a730edbd1368
3
+ metadata.gz: b46b97f10222c83aae520b8c1d91ca2385770241
4
+ data.tar.gz: f27f477e52eea0efb2d9d8a4a8f8186c6cd9b388
5
5
  SHA512:
6
- metadata.gz: e5ea60e64c2ee010d37e88af1e12243025e878f165826a810a208252412afcba9b9b57a771a50fee8a0c61b3742cf52db7575be242dd95e3f86d3a06751fae1d
7
- data.tar.gz: 8a86db0eed7d016c89e7d846f9a582348b7fe408e82b5c2be08b9c3554b50bda8a365caa4ba18339cec243a722426cc5c63d5e3be874645df3e647933eb4d5fd
6
+ metadata.gz: aebf27289b35eb6841a27f1014ed901310adb1bbb7ef8cdd997b31f22883c911029c427a97cf6b1196af1c409f0176eb078923b502f862226e39a48afd467fdc
7
+ data.tar.gz: 0e8044fa0a5e26be038c74bac517faec4a4b873fb8ffe7a53c982e018e0425675672a23a1956469cb50fb2f819d0d4aaa15c002550d62bc28aba65fe406a875d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stylr (0.0.13)
4
+ stylr (0.0.14)
5
5
  main (~> 5.2, >= 5.2.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -30,6 +30,8 @@ Optionally checks for some metaprogramming, which you might not want in a large,
30
30
  * <code>module_eval</code>
31
31
  * <code>define_method</code>
32
32
  * <code>send</code>
33
+ * <code>def method_missing</code>
34
+ * <code>def respond_to_missing?</code>
33
35
 
34
36
  All of these things are configurable via yml. See "stylr.yml" in the repo. Whatever directory you run stylr from will look for stylr.yml.
35
37
 
data/lib/stylr/lint.rb CHANGED
@@ -89,7 +89,9 @@ class Lint
89
89
  /===/ => :triple_equals,
90
90
  /[^\s]\+/ => :no_operator_spaces,
91
91
  /\+[^\s=]/ => :no_operator_spaces,
92
- /[^\s]-/ => :no_operator_spaces
92
+ /[^\s]-/ => :no_operator_spaces,
93
+ /![^\S\n]/ => :space_after_bang,
94
+ /\s\?\s.*\s\?\s/ => :nested_ternary
93
95
  }.delete_if { |_, v| !@config[v.to_s] }
94
96
 
95
97
  @exception_violations = {
@@ -134,7 +136,9 @@ class Lint
134
136
  :comma_spacing => "No space after a comma.",
135
137
  :no_soft_tabs => "Used tab characters; please use soft tabs.",
136
138
  :triple_equals => "Use of triple-equals.",
137
- :no_operator_spaces => "Please use spaces around operators."
139
+ :no_operator_spaces => "Please use spaces around operators.",
140
+ :space_after_bang => "Space after !.",
141
+ :nested_ternary => "Nested ternary expressions."
138
142
  }
139
143
  end
140
144
 
data/lib/stylr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Stylr
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
data/spec/lint_spec.rb CHANGED
@@ -101,6 +101,22 @@ module Stylr
101
101
  end
102
102
  end
103
103
 
104
+ context "no space after !" do
105
+ it "space after ! is bad" do
106
+ l.violation?("if ! condition").should be_true
107
+ end
108
+
109
+ it "line ending with ! is fine" do
110
+ l.violation?("shitty_rails_object.save!").should be_false
111
+ end
112
+ end
113
+
114
+ context "nested ternaries" do
115
+ it "do not nest ternaries for chrissake" do
116
+ l.violation?("x = y ? (x < 2 ? 5 : 2) : 55").should be_true
117
+ end
118
+ end
119
+
104
120
  context "soft tabs" do
105
121
  it "don't use actual tabs" do
106
122
  l.violation?("\t").should be_true
data/stylr.yml CHANGED
@@ -22,3 +22,5 @@ used_method_missing: true
22
22
  used_respond_to_missing: true
23
23
  dynamic_invocation: true
24
24
  triple_equals: true
25
+ space_after_bang: true
26
+ nested_ternary: true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stylr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Billie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-16 00:00:00.000000000 Z
11
+ date: 2014-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: main