suspiciouss 0.1.1 → 0.1.2
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/lib/suspiciouss/linter.rb +32 -5
- data/lib/suspiciouss/version.rb +1 -1
- data/spec/linter_spec.rb +83 -0
- data/suspiciouss.gemspec +1 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e351f0df749a63d636445a4d46a097904ed575f
|
4
|
+
data.tar.gz: 700601a65138cbabb863036b1d6e64e47687b269
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3fb9ed22350534bf844d65a48f5dc1bbac3babb0e1387193d1a651db6207303d9d8170218e8154d21f42bddae15e8c38863430fcbcd5e1a62d234417725ba73
|
7
|
+
data.tar.gz: 85cbca6c9b26aaefb114fc0ab16a16d1c4d7918cda9d680889a4cfa1c5d1ac5783b86269a601af778076349a17c67dd2022521e0e76b027b68d8d8ce9f3416cf
|
data/lib/suspiciouss/linter.rb
CHANGED
@@ -37,6 +37,10 @@ module Suspiciouss
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
def suggestions_to_use
|
41
|
+
included_suggestions.reject { |s| excluded_suggestions.include?(s) }
|
42
|
+
end
|
43
|
+
|
40
44
|
private
|
41
45
|
|
42
46
|
# Detects if the diff block references a known file type
|
@@ -70,16 +74,39 @@ module Suspiciouss
|
|
70
74
|
formatter.new(@result).format
|
71
75
|
end
|
72
76
|
|
73
|
-
#
|
77
|
+
# Returns a line without the "+ " added by diff
|
78
|
+
def strip_diff_syntax(line)
|
79
|
+
line[2..-1]
|
80
|
+
end
|
81
|
+
|
74
82
|
def known_suggestions
|
75
|
-
@known_suggestions ||=
|
83
|
+
@known_suggestions ||= suggestions_to_use.map do |suggestion_class|
|
76
84
|
SUGGESTIONS.const_get(suggestion_class).new
|
77
85
|
end
|
78
86
|
end
|
79
87
|
|
80
|
-
|
81
|
-
|
82
|
-
|
88
|
+
def included_suggestions
|
89
|
+
return SUGGESTIONS.constants unless config.has_key?(:include)
|
90
|
+
SUGGESTIONS.constants.select { |s| config[:include].include?(s.to_s) }
|
91
|
+
end
|
92
|
+
|
93
|
+
def excluded_suggestions
|
94
|
+
return [] unless config.has_key?(:exclude)
|
95
|
+
SUGGESTIONS.constants.select { |s| config[:exclude].include?(s.to_s) }
|
96
|
+
end
|
97
|
+
|
98
|
+
def config
|
99
|
+
return {} unless has_config?
|
100
|
+
|
101
|
+
@config ||= YAML::load(File.open(config_file))
|
102
|
+
end
|
103
|
+
|
104
|
+
def has_config?
|
105
|
+
File.exists?(config_file)
|
106
|
+
end
|
107
|
+
|
108
|
+
def config_file
|
109
|
+
'.suspiciouss.yml'
|
83
110
|
end
|
84
111
|
end
|
85
112
|
end
|
data/lib/suspiciouss/version.rb
CHANGED
data/spec/linter_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'fakefs/spec_helpers'
|
2
3
|
|
3
4
|
describe Suspiciouss::Linter do
|
4
5
|
|
@@ -25,4 +26,86 @@ describe Suspiciouss::Linter do
|
|
25
26
|
it { expect(subject).to eq output }
|
26
27
|
end
|
27
28
|
end
|
29
|
+
|
30
|
+
describe '#suggestions_to_use' do
|
31
|
+
include FakeFS::SpecHelpers
|
32
|
+
|
33
|
+
let(:suggestions_to_use) { subject.suggestions_to_use.map(&:to_s) }
|
34
|
+
|
35
|
+
it 'is a list of Linters' do
|
36
|
+
expect(suggestions_to_use).to match_array(%w(
|
37
|
+
CamelCase
|
38
|
+
Indentation
|
39
|
+
Overqualifying
|
40
|
+
StylingIds
|
41
|
+
StylingJsPrefix
|
42
|
+
Underscores
|
43
|
+
ZeroUnits
|
44
|
+
))
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'when we have a config file that specifies what to include' do
|
48
|
+
before do
|
49
|
+
File.open(".suspiciouss.yml", "w") do |f|
|
50
|
+
f.write({
|
51
|
+
:include => [
|
52
|
+
'CamelCase'
|
53
|
+
]
|
54
|
+
}.to_yaml)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'only includes those suggestions' do
|
59
|
+
expect(suggestions_to_use).to match_array(%w(
|
60
|
+
CamelCase
|
61
|
+
))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'when we have a config file that specifies what to exclude' do
|
66
|
+
before do
|
67
|
+
File.open(".suspiciouss.yml", "w") do |f|
|
68
|
+
f.write({
|
69
|
+
:exclude => [
|
70
|
+
'StylingIds',
|
71
|
+
'Indentation'
|
72
|
+
]
|
73
|
+
}.to_yaml)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'excludes those suggestions' do
|
78
|
+
expect(suggestions_to_use).to match_array(%w(
|
79
|
+
CamelCase
|
80
|
+
Overqualifying
|
81
|
+
StylingJsPrefix
|
82
|
+
Underscores
|
83
|
+
ZeroUnits
|
84
|
+
))
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'when we have a config file that specifies what to include _and_ exclude' do
|
89
|
+
before do
|
90
|
+
File.open(".suspiciouss.yml", "w") do |f|
|
91
|
+
f.write({
|
92
|
+
:include => [
|
93
|
+
'CamelCase',
|
94
|
+
'StylingIds'
|
95
|
+
],
|
96
|
+
:exclude => [
|
97
|
+
'StylingIds',
|
98
|
+
'Indentation'
|
99
|
+
]
|
100
|
+
}.to_yaml)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'the includes overrides the excludes' do
|
105
|
+
expect(suggestions_to_use).to match_array(%w(
|
106
|
+
CamelCase
|
107
|
+
))
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
28
111
|
end
|
data/suspiciouss.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: suspiciouss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Cruz Horts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: fakefs
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description:
|
84
98
|
email:
|
85
99
|
executables:
|
@@ -143,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
157
|
version: '0'
|
144
158
|
requirements: []
|
145
159
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.
|
160
|
+
rubygems_version: 2.2.2
|
147
161
|
signing_key:
|
148
162
|
specification_version: 4
|
149
163
|
summary: Reports common CSS/Sass/Less errors
|
@@ -162,3 +176,4 @@ test_files:
|
|
162
176
|
- spec/suggestions/styling_js_prefix_spec.rb
|
163
177
|
- spec/suggestions/underscores_spec.rb
|
164
178
|
- spec/suggestions/zero_units_spec.rb
|
179
|
+
has_rdoc:
|