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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/stylr/lint.rb +6 -2
- data/lib/stylr/version.rb +1 -1
- data/spec/lint_spec.rb +16 -0
- data/stylr.yml +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b46b97f10222c83aae520b8c1d91ca2385770241
|
4
|
+
data.tar.gz: f27f477e52eea0efb2d9d8a4a8f8186c6cd9b388
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aebf27289b35eb6841a27f1014ed901310adb1bbb7ef8cdd997b31f22883c911029c427a97cf6b1196af1c409f0176eb078923b502f862226e39a48afd467fdc
|
7
|
+
data.tar.gz: 0e8044fa0a5e26be038c74bac517faec4a4b873fb8ffe7a53c982e018e0425675672a23a1956469cb50fb2f819d0d4aaa15c002550d62bc28aba65fe406a875d
|
data/Gemfile.lock
CHANGED
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
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
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.
|
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-
|
11
|
+
date: 2014-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: main
|