warder 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/features/checks_for_all_issues.feature +3 -1
- data/features/step_definitions/detects_code_smells_steps.rb +1 -1
- data/features/step_definitions/run_steps.rb +2 -1
- data/features/step_definitions/validates_coffeescript_style_guide_steps.rb +12 -0
- data/features/step_definitions/{validates_style_guide_steps.rb → validates_ruby_style_guide_steps.rb} +0 -0
- data/features/validates_coffeescript_style_guide.feature +29 -0
- data/features/{validates_style_guide.feature → validates_ruby_style_guide.feature} +2 -2
- data/lib/warder.rb +1 -0
- data/lib/warder/code_smells_runner.rb +1 -1
- data/lib/warder/coffee_lint_runner.rb +37 -0
- data/lib/warder/coffee_lint_runner/lint_runner.rb +21 -0
- data/lib/warder/coffee_lint_runner/message_formatter.rb +19 -0
- data/lib/warder/coffee_lint_runner/message_line_formatter.rb +31 -0
- data/lib/warder/style_guide_runner.rb +1 -1
- data/lib/warder/version.rb +2 -2
- data/spec/fixtures/invalid_coffee_lint.coffee +6 -0
- data/spec/fixtures/invalid_rails_app/app/assets/javascripts/invalid_coffee_lint.coffee +6 -0
- data/spec/fixtures/valid_coffee_lint.coffee +6 -0
- data/spec/fixtures/valid_rails_app/app/assets/javascripts/valid.coffee +6 -0
- data/warder.gemspec +3 -2
- metadata +48 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 497806d6de8caaabfeeef4bb2a0f282516fc99b4
|
4
|
+
data.tar.gz: 3fee0b32c6c3e56f3b76b8e8e6f5ba372c707295
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e23cb77a50c305686c4036adc49b26f82d09fc6ece6a947b51d04e65d637a9e8d2f035c578751854041de73b3c00537c91708fc02ecebc501c6a9c061aa7dae
|
7
|
+
data.tar.gz: 868c4abad60f965ae17bfc46b960c1cf1373cf2c877ee708148b4120a3d8f3429b680e6d050808348aeb20f0e46d2817afd834c6d9acef5fc6995b45ea603e94
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Warder
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/yltsrc/warder.
|
4
|
-
[![Code Climate](https://codeclimate.com/github/yltsrc/warder.
|
5
|
-
[![Dependency Status](https://gemnasium.com/yltsrc/warder.
|
3
|
+
[![Build Status](https://travis-ci.org/yltsrc/warder.svg?branch=master)](https://travis-ci.org/yltsrc/warder)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/yltsrc/warder.svg)](https://codeclimate.com/github/yltsrc/warder)
|
5
|
+
[![Dependency Status](https://gemnasium.com/yltsrc/warder.svg)](https://gemnasium.com/yltsrc/warder)
|
6
6
|
|
7
7
|
## Getting started
|
8
8
|
|
@@ -55,6 +55,10 @@ You may also see, how your rails app meets Sandi Metz rules:
|
|
55
55
|
|
56
56
|
$ warder --sandi-rules
|
57
57
|
|
58
|
+
You can validate not only ruby files, but also coffeescript files:
|
59
|
+
|
60
|
+
$ warder --coffee-lint
|
61
|
+
|
58
62
|
## Installation
|
59
63
|
|
60
64
|
Add this line to your application's Gemfile:
|
@@ -16,6 +16,7 @@ Feature: checks for all issues
|
|
16
16
|
Then warder detects rails best practices issues
|
17
17
|
Then warder detects rails security issues
|
18
18
|
Then warder detects gem freshness issues
|
19
|
+
Then warder detects coffee lint issues
|
19
20
|
Then the exit status should be 0
|
20
21
|
|
21
22
|
Scenario: run warder with enabled rails option on invalid project
|
@@ -31,4 +32,5 @@ Feature: checks for all issues
|
|
31
32
|
Then warder detects rails best practices issues
|
32
33
|
Then warder detects rails security issues
|
33
34
|
Then warder detects gem freshness issues
|
34
|
-
Then
|
35
|
+
Then warder detects coffee lint issues
|
36
|
+
Then the exit status should be 10
|
@@ -8,6 +8,7 @@ end
|
|
8
8
|
|
9
9
|
Given(/^I have (\w+) file in directory$/) do |name|
|
10
10
|
@filename = "#{name}.rb"
|
11
|
+
@filename = "#{name}.coffee" unless File.exist? "spec/fixtures/#{@filename}"
|
11
12
|
FileUtils.ln_s "../../spec/fixtures/#{@filename}", 'tmp/aruba/'
|
12
13
|
expect(`ls tmp/aruba`).to match(@filename)
|
13
14
|
end
|
@@ -28,7 +29,7 @@ end
|
|
28
29
|
|
29
30
|
def command_output_for_project_or_file(cmd)
|
30
31
|
if @filename
|
31
|
-
`cd spec/fixtures/ && #{cmd}
|
32
|
+
`cd spec/fixtures/ && #{cmd} #{'./' unless cmd == 'reek'}#{@filename}`
|
32
33
|
elsif @projectname
|
33
34
|
`cd spec/fixtures/#{@projectname} && #{cmd} ./`
|
34
35
|
else
|
@@ -0,0 +1,12 @@
|
|
1
|
+
def executing_coffee_lint
|
2
|
+
"executing 'coffeelint .'"
|
3
|
+
end
|
4
|
+
|
5
|
+
def coffee_lint_output
|
6
|
+
output = command_output_for_project_or_file('coffeelint.rb -r .')
|
7
|
+
.split("\n")
|
8
|
+
.reject { |line| !line.match(/✗ #\d+:/) }
|
9
|
+
output.map do |str|
|
10
|
+
str.gsub("\e[32m", '').gsub("\e[0m", '').sub('✗', 'ERROR:')
|
11
|
+
end.join("\n")
|
12
|
+
end
|
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Feature: check coffeescript style guide
|
2
|
+
In order to check coffeescript style guide
|
3
|
+
As a coffeescript developer
|
4
|
+
I want to run warder with --coffee-lint option
|
5
|
+
|
6
|
+
Scenario: run warder with enabled coffee lint option
|
7
|
+
Given I have valid_coffee_lint file in directory
|
8
|
+
When I run `warder --coffee-lint`
|
9
|
+
Then warder detects coffee lint issues
|
10
|
+
Then the exit status should be 0
|
11
|
+
|
12
|
+
Scenario: run warder with enabled coffee lint option on invalid file
|
13
|
+
Given I have invalid_coffee_lint file in directory
|
14
|
+
When I run `warder --coffee-lint`
|
15
|
+
Then warder detects coffee lint issues
|
16
|
+
Then the exit status should be 1
|
17
|
+
|
18
|
+
Scenario: run warder with enabled coffee lint option on valid file only
|
19
|
+
Given I have valid_coffee_lint file in directory
|
20
|
+
And I have invalid_coffee_lint file in directory
|
21
|
+
When I run `warder --coffee-lint valid_coffee_lint.coffee`
|
22
|
+
Then warder does nothing
|
23
|
+
Then the exit status should be 0
|
24
|
+
|
25
|
+
Scenario: run warder with disabled coffee lint option on invalid file
|
26
|
+
Given I have invalid_coffee_lint file in directory
|
27
|
+
When I run `warder --no-coffee-lint`
|
28
|
+
Then warder does nothing
|
29
|
+
Then the exit status should be 0
|
data/lib/warder.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
module Warder
|
2
|
+
# responsible for run coffeescript style guide validation
|
3
|
+
class CoffeeLintRunner < Runner
|
4
|
+
require 'warder/coffee_lint_runner/lint_runner'
|
5
|
+
require 'warder/coffee_lint_runner/message_formatter'
|
6
|
+
|
7
|
+
CLI_OPTION = 'g'
|
8
|
+
CLI_FULL_OPTION = 'coffee-lint'
|
9
|
+
DESCRIPTION = 'Run coffeescript style guide validation'
|
10
|
+
COMMAND_NAME = 'coffeelint'
|
11
|
+
FAILURE_REGEXP = /(?<issues>(WARN|ERROR))/
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def run_command
|
16
|
+
@stdout.puts(exec_msg) unless quiet?
|
17
|
+
lint_results.each do |filename, result|
|
18
|
+
next if result.empty?
|
19
|
+
yield "\n#{filename}\n#{MessageFormatter.new(result).format}"
|
20
|
+
end
|
21
|
+
@stdout.puts(stats_msg) if stats?
|
22
|
+
end
|
23
|
+
|
24
|
+
def lint_results
|
25
|
+
lint_results = {}
|
26
|
+
@options.files.split(' ').each do |filename|
|
27
|
+
next if filename.length == 0
|
28
|
+
lint_results.merge!(LintRunner.new(filename).result)
|
29
|
+
end
|
30
|
+
lint_results
|
31
|
+
end
|
32
|
+
|
33
|
+
def number_of_issues(line)
|
34
|
+
self.class::FAILURE_REGEXP.match(line) ? 1 : 0
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'coffeelint'
|
2
|
+
|
3
|
+
module Warder
|
4
|
+
# responsible for run coffeescript style guide validation
|
5
|
+
class CoffeeLintRunner
|
6
|
+
# responsible for coffeelint results
|
7
|
+
class LintRunner
|
8
|
+
def initialize(file_or_path)
|
9
|
+
@file_or_path = file_or_path
|
10
|
+
end
|
11
|
+
|
12
|
+
def result
|
13
|
+
if Dir.exist?(@file_or_path)
|
14
|
+
Coffeelint.lint_dir(@file_or_path)
|
15
|
+
else
|
16
|
+
{ @file_or_path => Coffeelint.lint_file(@file_or_path) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'warder/coffee_lint_runner/message_line_formatter'
|
2
|
+
|
3
|
+
module Warder
|
4
|
+
# responsible for run coffeescript style guide validation
|
5
|
+
class CoffeeLintRunner
|
6
|
+
# responsible for human readable result of coffeelint validation
|
7
|
+
class MessageFormatter
|
8
|
+
def initialize(result)
|
9
|
+
@result = result
|
10
|
+
end
|
11
|
+
|
12
|
+
def format
|
13
|
+
@result.map do |result|
|
14
|
+
MessageLineFormatter.new(result).format
|
15
|
+
end.join("\n")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Warder
|
2
|
+
# responsible for run coffeescript style guide validation
|
3
|
+
class CoffeeLintRunner
|
4
|
+
# responsible for human readable error message representation
|
5
|
+
class MessageLineFormatter
|
6
|
+
MESSAGE_KEY = 'message'.freeze
|
7
|
+
CONTEXT_KEY = 'context'.freeze
|
8
|
+
LEVEL_KEY = 'level'.freeze
|
9
|
+
LINE_NUMBER_KEY = 'lineNumber'.freeze
|
10
|
+
|
11
|
+
def initialize(result)
|
12
|
+
@result = result
|
13
|
+
end
|
14
|
+
|
15
|
+
def format
|
16
|
+
msg = [@result[MESSAGE_KEY], @result[CONTEXT_KEY]].join('. ')
|
17
|
+
[level, line_number, msg].join(': ')
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def line_number
|
23
|
+
"##{@result[LINE_NUMBER_KEY]}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def level
|
27
|
+
@result[LEVEL_KEY].upcase
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -3,7 +3,7 @@ module Warder
|
|
3
3
|
class StyleGuideRunner < Runner
|
4
4
|
CLI_OPTION = 'g'
|
5
5
|
CLI_FULL_OPTION = 'style-guide'
|
6
|
-
DESCRIPTION = 'Run style guide validation'
|
6
|
+
DESCRIPTION = 'Run ruby style guide validation'
|
7
7
|
COMMAND_NAME = 'rubocop --no-color --format clang'
|
8
8
|
FAILURE_REGEXP = /(?<issues>\d+|no) offense/
|
9
9
|
end
|
data/lib/warder/version.rb
CHANGED
data/warder.gemspec
CHANGED
@@ -19,14 +19,15 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_dependency 'rubocop', '~> 0.32'
|
22
|
-
spec.add_dependency 'reek', '~> 3.0'
|
23
|
-
spec.add_dependency 'flay', '~> 2.6.1'
|
22
|
+
spec.add_dependency 'reek', '~> 3.0', '>= 3.0.3'
|
23
|
+
spec.add_dependency 'flay', '~> 2.6', '>= 2.6.1'
|
24
24
|
spec.add_dependency 'flog', '~> 4.3'
|
25
25
|
spec.add_dependency 'mago', '~> 0.1'
|
26
26
|
spec.add_dependency 'brakeman', '~> 3.0'
|
27
27
|
spec.add_dependency 'rails_best_practices', '~> 1.15'
|
28
28
|
spec.add_dependency 'sandi_meter', '~> 1.2'
|
29
29
|
spec.add_dependency 'bundler-audit', '~> 0.3'
|
30
|
+
spec.add_dependency 'coffeelint', '~> 1.10'
|
30
31
|
|
31
32
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
32
33
|
spec.add_development_dependency 'rake', '~> 10.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yura Tolstik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -31,6 +31,9 @@ dependencies:
|
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '3.0'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 3.0.3
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,11 +41,17 @@ dependencies:
|
|
38
41
|
- - "~>"
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '3.0'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.0.3
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: flay
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
51
|
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.6'
|
54
|
+
- - ">="
|
46
55
|
- !ruby/object:Gem::Version
|
47
56
|
version: 2.6.1
|
48
57
|
type: :runtime
|
@@ -50,6 +59,9 @@ dependencies:
|
|
50
59
|
version_requirements: !ruby/object:Gem::Requirement
|
51
60
|
requirements:
|
52
61
|
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '2.6'
|
64
|
+
- - ">="
|
53
65
|
- !ruby/object:Gem::Version
|
54
66
|
version: 2.6.1
|
55
67
|
- !ruby/object:Gem::Dependency
|
@@ -136,6 +148,20 @@ dependencies:
|
|
136
148
|
- - "~>"
|
137
149
|
- !ruby/object:Gem::Version
|
138
150
|
version: '0.3'
|
151
|
+
- !ruby/object:Gem::Dependency
|
152
|
+
name: coffeelint
|
153
|
+
requirement: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - "~>"
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '1.10'
|
158
|
+
type: :runtime
|
159
|
+
prerelease: false
|
160
|
+
version_requirements: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - "~>"
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '1.10'
|
139
165
|
- !ruby/object:Gem::Dependency
|
140
166
|
name: bundler
|
141
167
|
requirement: !ruby/object:Gem::Requirement
|
@@ -261,9 +287,11 @@ files:
|
|
261
287
|
- features/step_definitions/run_steps.rb
|
262
288
|
- features/step_definitions/show_version_steps.rb
|
263
289
|
- features/step_definitions/statistics_steps.rb
|
264
|
-
- features/step_definitions/
|
290
|
+
- features/step_definitions/validates_coffeescript_style_guide_steps.rb
|
291
|
+
- features/step_definitions/validates_ruby_style_guide_steps.rb
|
265
292
|
- features/support/env.rb
|
266
|
-
- features/
|
293
|
+
- features/validates_coffeescript_style_guide.feature
|
294
|
+
- features/validates_ruby_style_guide.feature
|
267
295
|
- lib/warder.rb
|
268
296
|
- lib/warder/bundle_audit_runner.rb
|
269
297
|
- lib/warder/cli.rb
|
@@ -271,6 +299,10 @@ files:
|
|
271
299
|
- lib/warder/code_complexity_runner.rb
|
272
300
|
- lib/warder/code_duplication_runner.rb
|
273
301
|
- lib/warder/code_smells_runner.rb
|
302
|
+
- lib/warder/coffee_lint_runner.rb
|
303
|
+
- lib/warder/coffee_lint_runner/lint_runner.rb
|
304
|
+
- lib/warder/coffee_lint_runner/message_formatter.rb
|
305
|
+
- lib/warder/coffee_lint_runner/message_line_formatter.rb
|
274
306
|
- lib/warder/magick_numbers_runner.rb
|
275
307
|
- lib/warder/rails_advice_runner.rb
|
276
308
|
- lib/warder/rails_security_runner.rb
|
@@ -281,10 +313,12 @@ files:
|
|
281
313
|
- spec/fixtures/invalid_code_complexity.rb
|
282
314
|
- spec/fixtures/invalid_code_duplication.rb
|
283
315
|
- spec/fixtures/invalid_code_smells.rb
|
316
|
+
- spec/fixtures/invalid_coffee_lint.coffee
|
284
317
|
- spec/fixtures/invalid_magick_numbers.rb
|
285
318
|
- spec/fixtures/invalid_rails_app/Gemfile
|
286
319
|
- spec/fixtures/invalid_rails_app/Gemfile_lock
|
287
320
|
- spec/fixtures/invalid_rails_app/Rakefile
|
321
|
+
- spec/fixtures/invalid_rails_app/app/assets/javascripts/invalid_coffee_lint.coffee
|
288
322
|
- spec/fixtures/invalid_rails_app/app/controllers/application_controller.rb
|
289
323
|
- spec/fixtures/invalid_rails_app/app/models/user.rb
|
290
324
|
- spec/fixtures/invalid_rails_app/app/views/layouts/application.html.erb
|
@@ -310,9 +344,11 @@ files:
|
|
310
344
|
- spec/fixtures/invalid_style_guide.rb
|
311
345
|
- spec/fixtures/strictly_invalid_style_guide.rb
|
312
346
|
- spec/fixtures/valid.rb
|
347
|
+
- spec/fixtures/valid_coffee_lint.coffee
|
313
348
|
- spec/fixtures/valid_rails_app/Gemfile
|
314
349
|
- spec/fixtures/valid_rails_app/Gemfile_lock
|
315
350
|
- spec/fixtures/valid_rails_app/Rakefile
|
351
|
+
- spec/fixtures/valid_rails_app/app/assets/javascripts/valid.coffee
|
316
352
|
- spec/fixtures/valid_rails_app/app/controllers/application_controller.rb
|
317
353
|
- spec/fixtures/valid_rails_app/app/views/layouts/application.html.erb
|
318
354
|
- spec/fixtures/valid_rails_app/config.ru
|
@@ -382,16 +418,20 @@ test_files:
|
|
382
418
|
- features/step_definitions/run_steps.rb
|
383
419
|
- features/step_definitions/show_version_steps.rb
|
384
420
|
- features/step_definitions/statistics_steps.rb
|
385
|
-
- features/step_definitions/
|
421
|
+
- features/step_definitions/validates_coffeescript_style_guide_steps.rb
|
422
|
+
- features/step_definitions/validates_ruby_style_guide_steps.rb
|
386
423
|
- features/support/env.rb
|
387
|
-
- features/
|
424
|
+
- features/validates_coffeescript_style_guide.feature
|
425
|
+
- features/validates_ruby_style_guide.feature
|
388
426
|
- spec/fixtures/invalid_code_complexity.rb
|
389
427
|
- spec/fixtures/invalid_code_duplication.rb
|
390
428
|
- spec/fixtures/invalid_code_smells.rb
|
429
|
+
- spec/fixtures/invalid_coffee_lint.coffee
|
391
430
|
- spec/fixtures/invalid_magick_numbers.rb
|
392
431
|
- spec/fixtures/invalid_rails_app/Gemfile
|
393
432
|
- spec/fixtures/invalid_rails_app/Gemfile_lock
|
394
433
|
- spec/fixtures/invalid_rails_app/Rakefile
|
434
|
+
- spec/fixtures/invalid_rails_app/app/assets/javascripts/invalid_coffee_lint.coffee
|
395
435
|
- spec/fixtures/invalid_rails_app/app/controllers/application_controller.rb
|
396
436
|
- spec/fixtures/invalid_rails_app/app/models/user.rb
|
397
437
|
- spec/fixtures/invalid_rails_app/app/views/layouts/application.html.erb
|
@@ -417,9 +457,11 @@ test_files:
|
|
417
457
|
- spec/fixtures/invalid_style_guide.rb
|
418
458
|
- spec/fixtures/strictly_invalid_style_guide.rb
|
419
459
|
- spec/fixtures/valid.rb
|
460
|
+
- spec/fixtures/valid_coffee_lint.coffee
|
420
461
|
- spec/fixtures/valid_rails_app/Gemfile
|
421
462
|
- spec/fixtures/valid_rails_app/Gemfile_lock
|
422
463
|
- spec/fixtures/valid_rails_app/Rakefile
|
464
|
+
- spec/fixtures/valid_rails_app/app/assets/javascripts/valid.coffee
|
423
465
|
- spec/fixtures/valid_rails_app/app/controllers/application_controller.rb
|
424
466
|
- spec/fixtures/valid_rails_app/app/views/layouts/application.html.erb
|
425
467
|
- spec/fixtures/valid_rails_app/config.ru
|