codeguard 0.1.0
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 +7 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +880 -0
- data/Gemfile +7 -0
- data/LICENSE +21 -0
- data/README.md +20 -0
- data/Rakefile +26 -0
- data/bin/codeguard +9 -0
- data/codeguard.gemspec +28 -0
- data/config/.gitmessage +16 -0
- data/config/.rubocop.yml +880 -0
- data/config/.scss-lint.yml +234 -0
- data/config/coffeelint.json +135 -0
- data/config/jshint.yml +21 -0
- data/eat-glitter.jpg +0 -0
- data/lib/codeguard/cli.rb +17 -0
- data/lib/codeguard/coffeelint.rb +13 -0
- data/lib/codeguard/diff.rb +44 -0
- data/lib/codeguard/git_message.rb +17 -0
- data/lib/codeguard/install.rb +46 -0
- data/lib/codeguard/js_hint.rb +13 -0
- data/lib/codeguard/rubocop.rb +13 -0
- data/lib/codeguard/scss_lint.rb +13 -0
- data/lib/codeguard/version.rb +3 -0
- data/lib/codeguard.rb +54 -0
- metadata +155 -0
@@ -0,0 +1,234 @@
|
|
1
|
+
# Default application configuration that all configurations inherit from.
|
2
|
+
|
3
|
+
scss_files: "**/*.scss"
|
4
|
+
plugin_directories: ['.scss-linters']
|
5
|
+
|
6
|
+
# List of gem names to load custom linters from (make sure they are already
|
7
|
+
# installed)
|
8
|
+
plugin_gems: []
|
9
|
+
|
10
|
+
linters:
|
11
|
+
BangFormat:
|
12
|
+
enabled: true
|
13
|
+
space_before_bang: true
|
14
|
+
space_after_bang: false
|
15
|
+
|
16
|
+
BemDepth:
|
17
|
+
enabled: false
|
18
|
+
max_elements: 1
|
19
|
+
|
20
|
+
BorderZero:
|
21
|
+
enabled: true
|
22
|
+
convention: zero # or `none`
|
23
|
+
|
24
|
+
ColorKeyword:
|
25
|
+
enabled: true
|
26
|
+
|
27
|
+
ColorVariable:
|
28
|
+
enabled: true
|
29
|
+
|
30
|
+
Comment:
|
31
|
+
enabled: true
|
32
|
+
|
33
|
+
DebugStatement:
|
34
|
+
enabled: true
|
35
|
+
|
36
|
+
DeclarationOrder:
|
37
|
+
enabled: true
|
38
|
+
|
39
|
+
DisableLinterReason:
|
40
|
+
enabled: false
|
41
|
+
|
42
|
+
DuplicateProperty:
|
43
|
+
enabled: true
|
44
|
+
|
45
|
+
ElsePlacement:
|
46
|
+
enabled: true
|
47
|
+
style: same_line # or 'new_line'
|
48
|
+
|
49
|
+
EmptyLineBetweenBlocks:
|
50
|
+
enabled: true
|
51
|
+
ignore_single_line_blocks: true
|
52
|
+
|
53
|
+
EmptyRule:
|
54
|
+
enabled: true
|
55
|
+
|
56
|
+
ExtendDirective:
|
57
|
+
enabled: false
|
58
|
+
|
59
|
+
FinalNewline:
|
60
|
+
enabled: true
|
61
|
+
present: true
|
62
|
+
|
63
|
+
HexLength:
|
64
|
+
enabled: true
|
65
|
+
style: short # or 'long'
|
66
|
+
|
67
|
+
HexNotation:
|
68
|
+
enabled: true
|
69
|
+
style: lowercase # or 'uppercase'
|
70
|
+
|
71
|
+
HexValidation:
|
72
|
+
enabled: true
|
73
|
+
|
74
|
+
IdSelector:
|
75
|
+
enabled: true
|
76
|
+
|
77
|
+
ImportantRule:
|
78
|
+
enabled: true
|
79
|
+
|
80
|
+
ImportPath:
|
81
|
+
enabled: true
|
82
|
+
leading_underscore: false
|
83
|
+
filename_extension: false
|
84
|
+
|
85
|
+
Indentation:
|
86
|
+
enabled: true
|
87
|
+
allow_non_nested_indentation: false
|
88
|
+
character: space # or 'tab'
|
89
|
+
width: 2
|
90
|
+
|
91
|
+
LeadingZero:
|
92
|
+
enabled: true
|
93
|
+
style: exclude_zero # or 'include_zero'
|
94
|
+
|
95
|
+
MergeableSelector:
|
96
|
+
enabled: true
|
97
|
+
force_nesting: true
|
98
|
+
|
99
|
+
NameFormat:
|
100
|
+
enabled: true
|
101
|
+
allow_leading_underscore: true
|
102
|
+
convention: hyphenated_lowercase # or 'camel_case', or 'snake_case', or a regex pattern
|
103
|
+
|
104
|
+
NestingDepth:
|
105
|
+
enabled: true
|
106
|
+
max_depth: 3
|
107
|
+
ignore_parent_selectors: false
|
108
|
+
|
109
|
+
PlaceholderInExtend:
|
110
|
+
enabled: true
|
111
|
+
|
112
|
+
PropertyCount:
|
113
|
+
enabled: false
|
114
|
+
include_nested: false
|
115
|
+
max_properties: 10
|
116
|
+
|
117
|
+
PropertySortOrder:
|
118
|
+
enabled: true
|
119
|
+
ignore_unspecified: false
|
120
|
+
min_properties: 2
|
121
|
+
separate_groups: false
|
122
|
+
|
123
|
+
PropertySpelling:
|
124
|
+
enabled: true
|
125
|
+
extra_properties: []
|
126
|
+
|
127
|
+
PropertyUnits:
|
128
|
+
enabled: true
|
129
|
+
global: [
|
130
|
+
'ch', 'em', 'ex', 'rem', # Font-relative lengths
|
131
|
+
'cm', 'in', 'mm', 'pc', 'pt', 'px', 'q', # Absolute lengths
|
132
|
+
'vh', 'vw', 'vmin', 'vmax', # Viewport-percentage lengths
|
133
|
+
'deg', 'grad', 'rad', 'turn', # Angle
|
134
|
+
'ms', 's', # Duration
|
135
|
+
'Hz', 'kHz', # Frequency
|
136
|
+
'dpi', 'dpcm', 'dppx', # Resolution
|
137
|
+
'%'] # Other
|
138
|
+
properties: {}
|
139
|
+
|
140
|
+
QualifyingElement:
|
141
|
+
enabled: true
|
142
|
+
allow_element_with_attribute: false
|
143
|
+
allow_element_with_class: false
|
144
|
+
allow_element_with_id: false
|
145
|
+
|
146
|
+
SelectorDepth:
|
147
|
+
enabled: true
|
148
|
+
max_depth: 3
|
149
|
+
|
150
|
+
SelectorFormat:
|
151
|
+
enabled: true
|
152
|
+
convention: hyphenated_lowercase # or 'strict_BEM', or 'hyphenated_BEM', or 'snake_case', or 'camel_case', or a regex pattern
|
153
|
+
|
154
|
+
Shorthand:
|
155
|
+
enabled: true
|
156
|
+
allowed_shorthands: [1, 2, 3]
|
157
|
+
|
158
|
+
SingleLinePerProperty:
|
159
|
+
enabled: true
|
160
|
+
allow_single_line_rule_sets: true
|
161
|
+
|
162
|
+
SingleLinePerSelector:
|
163
|
+
enabled: true
|
164
|
+
|
165
|
+
SpaceAfterComma:
|
166
|
+
enabled: true
|
167
|
+
style: one_space # or 'no_space', or 'at_least_one_space'
|
168
|
+
|
169
|
+
SpaceAfterPropertyColon:
|
170
|
+
enabled: true
|
171
|
+
style: one_space # or 'no_space', or 'at_least_one_space', or 'aligned'
|
172
|
+
|
173
|
+
SpaceAfterPropertyName:
|
174
|
+
enabled: true
|
175
|
+
|
176
|
+
SpaceAfterVariableName:
|
177
|
+
enabled: true
|
178
|
+
|
179
|
+
SpaceAroundOperator:
|
180
|
+
enabled: true
|
181
|
+
style: one_space # or 'no_space'
|
182
|
+
|
183
|
+
SpaceBeforeBrace:
|
184
|
+
enabled: true
|
185
|
+
style: space # or 'new_line'
|
186
|
+
allow_single_line_padding: false
|
187
|
+
|
188
|
+
SpaceBetweenParens:
|
189
|
+
enabled: true
|
190
|
+
spaces: 0
|
191
|
+
|
192
|
+
StringQuotes:
|
193
|
+
enabled: true
|
194
|
+
style: single_quotes # or double_quotes
|
195
|
+
|
196
|
+
TrailingSemicolon:
|
197
|
+
enabled: true
|
198
|
+
|
199
|
+
TrailingWhitespace:
|
200
|
+
enabled: true
|
201
|
+
|
202
|
+
TrailingZero:
|
203
|
+
enabled: false
|
204
|
+
|
205
|
+
TransitionAll:
|
206
|
+
enabled: false
|
207
|
+
|
208
|
+
UnnecessaryMantissa:
|
209
|
+
enabled: true
|
210
|
+
|
211
|
+
UnnecessaryParentReference:
|
212
|
+
enabled: true
|
213
|
+
|
214
|
+
UrlFormat:
|
215
|
+
enabled: true
|
216
|
+
|
217
|
+
UrlQuotes:
|
218
|
+
enabled: true
|
219
|
+
|
220
|
+
VariableForProperty:
|
221
|
+
enabled: false
|
222
|
+
properties: []
|
223
|
+
|
224
|
+
VendorPrefix:
|
225
|
+
enabled: true
|
226
|
+
identifier_list: base
|
227
|
+
additional_identifiers: []
|
228
|
+
excluded_identifiers: []
|
229
|
+
|
230
|
+
ZeroUnit:
|
231
|
+
enabled: true
|
232
|
+
|
233
|
+
Compass::*:
|
234
|
+
enabled: false
|
@@ -0,0 +1,135 @@
|
|
1
|
+
{
|
2
|
+
"arrow_spacing": {
|
3
|
+
"level": "ignore"
|
4
|
+
},
|
5
|
+
"braces_spacing": {
|
6
|
+
"level": "ignore",
|
7
|
+
"spaces": 0,
|
8
|
+
"empty_object_spaces": 0
|
9
|
+
},
|
10
|
+
"camel_case_classes": {
|
11
|
+
"level": "error"
|
12
|
+
},
|
13
|
+
"coffeescript_error": {
|
14
|
+
"level": "error"
|
15
|
+
},
|
16
|
+
"colon_assignment_spacing": {
|
17
|
+
"level": "ignore",
|
18
|
+
"spacing": {
|
19
|
+
"left": 0,
|
20
|
+
"right": 0
|
21
|
+
}
|
22
|
+
},
|
23
|
+
"cyclomatic_complexity": {
|
24
|
+
"value": 10,
|
25
|
+
"level": "ignore"
|
26
|
+
},
|
27
|
+
"duplicate_key": {
|
28
|
+
"level": "error"
|
29
|
+
},
|
30
|
+
"empty_constructor_needs_parens": {
|
31
|
+
"level": "ignore"
|
32
|
+
},
|
33
|
+
"ensure_comprehensions": {
|
34
|
+
"level": "warn"
|
35
|
+
},
|
36
|
+
"eol_last": {
|
37
|
+
"level": "ignore"
|
38
|
+
},
|
39
|
+
"indentation": {
|
40
|
+
"value": 2,
|
41
|
+
"level": "error"
|
42
|
+
},
|
43
|
+
"line_endings": {
|
44
|
+
"level": "ignore",
|
45
|
+
"value": "unix"
|
46
|
+
},
|
47
|
+
"max_line_length": {
|
48
|
+
"value": 80,
|
49
|
+
"level": "error",
|
50
|
+
"limitComments": true
|
51
|
+
},
|
52
|
+
"missing_fat_arrows": {
|
53
|
+
"level": "ignore",
|
54
|
+
"is_strict": false
|
55
|
+
},
|
56
|
+
"newlines_after_classes": {
|
57
|
+
"value": 3,
|
58
|
+
"level": "ignore"
|
59
|
+
},
|
60
|
+
"no_backticks": {
|
61
|
+
"level": "error"
|
62
|
+
},
|
63
|
+
"no_debugger": {
|
64
|
+
"level": "warn",
|
65
|
+
"console": false
|
66
|
+
},
|
67
|
+
"no_empty_functions": {
|
68
|
+
"level": "ignore"
|
69
|
+
},
|
70
|
+
"no_empty_param_list": {
|
71
|
+
"level": "ignore"
|
72
|
+
},
|
73
|
+
"no_implicit_braces": {
|
74
|
+
"level": "ignore",
|
75
|
+
"strict": true
|
76
|
+
},
|
77
|
+
"no_implicit_parens": {
|
78
|
+
"strict": true,
|
79
|
+
"level": "ignore"
|
80
|
+
},
|
81
|
+
"no_interpolation_in_single_quotes": {
|
82
|
+
"level": "ignore"
|
83
|
+
},
|
84
|
+
"no_nested_string_interpolation": {
|
85
|
+
"level": "warn"
|
86
|
+
},
|
87
|
+
"no_plusplus": {
|
88
|
+
"level": "ignore"
|
89
|
+
},
|
90
|
+
"no_private_function_fat_arrows": {
|
91
|
+
"level": "warn"
|
92
|
+
},
|
93
|
+
"no_stand_alone_at": {
|
94
|
+
"level": "ignore"
|
95
|
+
},
|
96
|
+
"no_tabs": {
|
97
|
+
"level": "error"
|
98
|
+
},
|
99
|
+
"no_this": {
|
100
|
+
"level": "ignore"
|
101
|
+
},
|
102
|
+
"no_throwing_strings": {
|
103
|
+
"level": "error"
|
104
|
+
},
|
105
|
+
"no_trailing_semicolons": {
|
106
|
+
"level": "error"
|
107
|
+
},
|
108
|
+
"no_trailing_whitespace": {
|
109
|
+
"level": "error",
|
110
|
+
"allowed_in_comments": false,
|
111
|
+
"allowed_in_empty_lines": true
|
112
|
+
},
|
113
|
+
"no_unnecessary_double_quotes": {
|
114
|
+
"level": "ignore"
|
115
|
+
},
|
116
|
+
"no_unnecessary_fat_arrows": {
|
117
|
+
"level": "warn"
|
118
|
+
},
|
119
|
+
"non_empty_constructor_needs_parens": {
|
120
|
+
"level": "ignore"
|
121
|
+
},
|
122
|
+
"prefer_english_operator": {
|
123
|
+
"level": "ignore",
|
124
|
+
"doubleNotLevel": "ignore"
|
125
|
+
},
|
126
|
+
"space_operators": {
|
127
|
+
"level": "ignore"
|
128
|
+
},
|
129
|
+
"spacing_after_comma": {
|
130
|
+
"level": "ignore"
|
131
|
+
},
|
132
|
+
"transform_messes_up_line_numbers": {
|
133
|
+
"level": "warn"
|
134
|
+
}
|
135
|
+
}
|
data/config/jshint.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
files: ["**/*.js"] # No need to put app/assets/ or vendor/assets here
|
2
|
+
exclude_paths: []
|
3
|
+
options:
|
4
|
+
boss: true
|
5
|
+
browser: true
|
6
|
+
curly: true
|
7
|
+
eqeqeq: true
|
8
|
+
eqnull: true
|
9
|
+
expr: true
|
10
|
+
immed: true
|
11
|
+
indent: 2
|
12
|
+
latedef: true
|
13
|
+
newcap: true
|
14
|
+
noarg: true
|
15
|
+
sub: true
|
16
|
+
trailing: true
|
17
|
+
undef: true
|
18
|
+
unused: true
|
19
|
+
globals:
|
20
|
+
jQuery: true
|
21
|
+
"$": true
|
data/eat-glitter.jpg
ADDED
Binary file
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Codeguard
|
2
|
+
module CLI
|
3
|
+
AVAILABLE_OPTIONS = %w(install help diff)
|
4
|
+
|
5
|
+
module_function
|
6
|
+
|
7
|
+
def run(*args)
|
8
|
+
command = args.shift
|
9
|
+
unless AVAILABLE_OPTIONS.include?(command)
|
10
|
+
puts "Invalid option: #{command}"
|
11
|
+
command = :help
|
12
|
+
end
|
13
|
+
|
14
|
+
Codeguard.send(command || :help, *args)
|
15
|
+
end
|
16
|
+
end # module CLI
|
17
|
+
end # module Codeguard
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rainbow'
|
2
|
+
module Codeguard
|
3
|
+
class Diff
|
4
|
+
extend Forwardable
|
5
|
+
attr_accessor :lint, :message, :raw_diff
|
6
|
+
|
7
|
+
def self.perform(lint)
|
8
|
+
new(lint).tap(&:perform)
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(lint)
|
12
|
+
@lint = lint
|
13
|
+
end
|
14
|
+
|
15
|
+
def perform
|
16
|
+
self.raw_diff = Diffy::Diff.new(config_gem_path.to_s,
|
17
|
+
config_project_path.to_s,
|
18
|
+
source: 'files')
|
19
|
+
end
|
20
|
+
|
21
|
+
def diff
|
22
|
+
raw_diff.to_s(:color) unless diff_empty?
|
23
|
+
end
|
24
|
+
|
25
|
+
def message
|
26
|
+
if !File.exist?(config_project_path)
|
27
|
+
Rainbow("#{config_project_path} does not exists. " \
|
28
|
+
'Run `codeguard install`.').yellow
|
29
|
+
elsif !diff_empty?
|
30
|
+
Rainbow("#{config_project_path} was changed.").red
|
31
|
+
else
|
32
|
+
Rainbow("#{config_project_path} is OK!").green
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def diff_empty?
|
39
|
+
raw_diff.to_s.empty?
|
40
|
+
end
|
41
|
+
|
42
|
+
def_delegators :lint, :config_project_path, :config_gem_path
|
43
|
+
end # class Diff
|
44
|
+
end # module Codeguard
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Codeguard
|
2
|
+
module GitMessage
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def config_project_path
|
6
|
+
Pathname.new '.gitmessage'
|
7
|
+
end
|
8
|
+
|
9
|
+
def config_gem_path
|
10
|
+
Codeguard.config_path.join('.gitmessage')
|
11
|
+
end
|
12
|
+
|
13
|
+
def after_install
|
14
|
+
`git config commit.template .gitmessage`
|
15
|
+
end
|
16
|
+
end # module GitMessage
|
17
|
+
end # module Codeguard
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rainbow'
|
2
|
+
module Codeguard
|
3
|
+
class Install
|
4
|
+
extend Forwardable
|
5
|
+
attr_accessor :lint
|
6
|
+
|
7
|
+
def self.perform(lint)
|
8
|
+
new(lint).tap(&:perform)
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(lint)
|
12
|
+
@lint = lint
|
13
|
+
end
|
14
|
+
|
15
|
+
def perform
|
16
|
+
output = config_gem_path.read
|
17
|
+
prepare_dir
|
18
|
+
output = if write_to_file(config_project_path, output)
|
19
|
+
"File: #{config_project_path} was updated!"
|
20
|
+
else
|
21
|
+
"File: #{config_project_path} was created!"
|
22
|
+
end
|
23
|
+
puts Rainbow(output).green
|
24
|
+
|
25
|
+
lint.after_install if lint.respond_to?(:after_install)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def prepare_dir
|
31
|
+
dir = config_project_path.to_s[%r{(.*)\/[\w\.-]*}, 1]
|
32
|
+
FileUtils.mkdir_p(dir) unless dir.nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
def write_to_file(path, content)
|
36
|
+
if (updating = File.exist?(path))
|
37
|
+
FileUtils.chmod 'a+w', path
|
38
|
+
end
|
39
|
+
File.open(path, 'w+') { |f| f.write(content) }
|
40
|
+
FileUtils.chmod 'a-w', path
|
41
|
+
updating
|
42
|
+
end
|
43
|
+
|
44
|
+
def_delegators :lint, :config_project_path, :config_gem_path
|
45
|
+
end # class Install
|
46
|
+
end # module Codeguard
|
data/lib/codeguard.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'diffy'
|
2
|
+
require 'codeguard/install'
|
3
|
+
require 'codeguard/coffeelint'
|
4
|
+
require 'codeguard/js_hint'
|
5
|
+
require 'codeguard/rubocop'
|
6
|
+
require 'codeguard/scss_lint'
|
7
|
+
require 'codeguard/git_message'
|
8
|
+
require 'codeguard/diff'
|
9
|
+
|
10
|
+
module Codeguard
|
11
|
+
LINTERS = [Coffeelint, GitMessage, JSHint, Rubocop, SCSSLint]
|
12
|
+
|
13
|
+
module_function
|
14
|
+
|
15
|
+
def install
|
16
|
+
LINTERS.each do |lint|
|
17
|
+
Install.perform(lint)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def diff
|
22
|
+
lints = LINTERS.map do |lint|
|
23
|
+
diff = Diff.perform(lint)
|
24
|
+
[diff.diff, diff.message]
|
25
|
+
end
|
26
|
+
transposed = lints.transpose
|
27
|
+
puts transposed.first.compact
|
28
|
+
puts transposed.last.compact
|
29
|
+
end
|
30
|
+
|
31
|
+
def help
|
32
|
+
puts %(
|
33
|
+
codeguard help - show this message
|
34
|
+
codeguard install - install config for current project
|
35
|
+
codeguard diff - check if the files were not modified
|
36
|
+
|
37
|
+
The project will use configuration for:
|
38
|
+
- coffeelint (http://www.coffeelint.org/)
|
39
|
+
- js_hint (https://github.com/damian/jshint)
|
40
|
+
- rubocop (https://github.com/bbatsov/rubocop)
|
41
|
+
- scss_lint (https://github.com/brigade/scss-lint)
|
42
|
+
|
43
|
+
.gitmessage file will be added as a template in .git/config
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
def config_path
|
48
|
+
gem_root.join('config')
|
49
|
+
end
|
50
|
+
|
51
|
+
def gem_root
|
52
|
+
Pathname.new($LOAD_PATH.first).join('../')
|
53
|
+
end
|
54
|
+
end # module Codeguard
|