clint_eastwood 0.0.1
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 +31 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +75 -0
- data/LICENSE.txt +23 -0
- data/README.md +57 -0
- data/Rakefile +2 -0
- data/bin/clint +5 -0
- data/clint_eastwood.gemspec +30 -0
- data/config/rails_best_practices.yml +41 -0
- data/config/reek.yml +102 -0
- data/config/rubocop.yml +19 -0
- data/lib/better_rails_best_practices.rb +36 -0
- data/lib/better_reek.rb +13 -0
- data/lib/clint_eastwood/cli.rb +55 -0
- data/lib/clint_eastwood/version.rb +4 -0
- data/lib/clint_eastwood.rb +87 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2c81e2798cf9ea3dc99453fba15b6a3f4bf88d08
|
4
|
+
data.tar.gz: 4a34301d948579ed2c972fff0c0eb31e34334b5c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 54ac2b3e533fe4f8f42e5a24249bac1dc013a66c82e3818aac3d7370b141b8b1d6b3de31cacfea4a7294050ac7faf6ec461671a24151f89487a6812aaedef0b1
|
7
|
+
data.tar.gz: 5cf7f39880c6c7f2c8bd5260bbdf99e2e8c5d261f5d0777e7359a44844e686cb3f6c110c343225d154e3ec0b0691bbfb03d432767ea13e4b720faccaf37dec93
|
data/.gitignore
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
6
|
+
|
7
|
+
# Ignore bundler config
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Vagrant
|
11
|
+
.vagrant
|
12
|
+
|
13
|
+
# Chef solo
|
14
|
+
cookbooks
|
15
|
+
|
16
|
+
# Ignore the default SQLite database.
|
17
|
+
/db/*.sqlite3
|
18
|
+
|
19
|
+
# Ignore all logfiles and tempfiles.
|
20
|
+
/log/*.log
|
21
|
+
/tmp
|
22
|
+
|
23
|
+
.DS_Store
|
24
|
+
*.DS_Store
|
25
|
+
NOTES
|
26
|
+
|
27
|
+
# Ignore environment variables
|
28
|
+
.env
|
29
|
+
|
30
|
+
#gem release
|
31
|
+
*.gem
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
clint_eastwood (0.0.1)
|
5
|
+
rails_best_practices (~> 1.15.4)
|
6
|
+
reek (~> 1.3.7)
|
7
|
+
rubocop (~> 0.23.0)
|
8
|
+
thor (~> 0.19.1)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
activesupport (4.1.1)
|
14
|
+
i18n (~> 0.6, >= 0.6.9)
|
15
|
+
json (~> 1.7, >= 1.7.7)
|
16
|
+
minitest (~> 5.1)
|
17
|
+
thread_safe (~> 0.1)
|
18
|
+
tzinfo (~> 1.1)
|
19
|
+
ast (2.0.0)
|
20
|
+
awesome_print (1.2.0)
|
21
|
+
code_analyzer (0.4.5)
|
22
|
+
sexp_processor
|
23
|
+
colored (1.2)
|
24
|
+
erubis (2.7.0)
|
25
|
+
i18n (0.6.9)
|
26
|
+
json (1.8.1)
|
27
|
+
minitest (5.3.4)
|
28
|
+
parser (2.1.9)
|
29
|
+
ast (>= 1.1, < 3.0)
|
30
|
+
slop (~> 3.4, >= 3.4.5)
|
31
|
+
powerpack (0.0.9)
|
32
|
+
rails_best_practices (1.15.4)
|
33
|
+
activesupport
|
34
|
+
awesome_print
|
35
|
+
code_analyzer (>= 0.4.3)
|
36
|
+
colored
|
37
|
+
erubis
|
38
|
+
i18n
|
39
|
+
json
|
40
|
+
require_all
|
41
|
+
ruby-progressbar
|
42
|
+
rainbow (2.0.0)
|
43
|
+
rake (10.3.2)
|
44
|
+
reek (1.3.7)
|
45
|
+
rainbow
|
46
|
+
ruby2ruby (~> 2.0.8)
|
47
|
+
ruby_parser (~> 3.3)
|
48
|
+
sexp_processor
|
49
|
+
require_all (1.3.2)
|
50
|
+
rubocop (0.23.0)
|
51
|
+
json (>= 1.7.7, < 2)
|
52
|
+
parser (~> 2.1.9)
|
53
|
+
powerpack (~> 0.0.6)
|
54
|
+
rainbow (>= 1.99.1, < 3.0)
|
55
|
+
ruby-progressbar (~> 1.4)
|
56
|
+
ruby-progressbar (1.5.1)
|
57
|
+
ruby2ruby (2.0.8)
|
58
|
+
ruby_parser (~> 3.1)
|
59
|
+
sexp_processor (~> 4.0)
|
60
|
+
ruby_parser (3.6.1)
|
61
|
+
sexp_processor (~> 4.1)
|
62
|
+
sexp_processor (4.4.3)
|
63
|
+
slop (3.5.0)
|
64
|
+
thor (0.19.1)
|
65
|
+
thread_safe (0.3.4)
|
66
|
+
tzinfo (1.2.0)
|
67
|
+
thread_safe (~> 0.1)
|
68
|
+
|
69
|
+
PLATFORMS
|
70
|
+
ruby
|
71
|
+
|
72
|
+
DEPENDENCIES
|
73
|
+
bundler (~> 1.6)
|
74
|
+
clint_eastwood!
|
75
|
+
rake
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2014 Cloudspace
|
2
|
+
Developed by Joey Lorich (joey@cloudspace.com, www.josephlorich.net)
|
3
|
+
|
4
|
+
MIT License
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# ClintEastwood
|
2
|
+
|
3
|
+
The **C** loudspace **Lint** er for rails applications
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'clint_eastwood', :git => 'git://github.com/cloudspace/clint_eastwood.git'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
To run simply run `clint` while in the desired app root directory.
|
18
|
+
|
19
|
+
## options
|
20
|
+
#### Path
|
21
|
+
Allows to to specify a project path other than the current directory
|
22
|
+
|
23
|
+
```
|
24
|
+
clint --path /path/to/my/project
|
25
|
+
```
|
26
|
+
|
27
|
+
#### Lint
|
28
|
+
Allows you to specify which subdirectories to lint (default is `app`, `lib`, `config`, `spec`)
|
29
|
+
|
30
|
+
```
|
31
|
+
clint --lint app lib bin
|
32
|
+
```
|
33
|
+
|
34
|
+
#### Disable modules
|
35
|
+
The following options are availabe to disable the individual linter modules
|
36
|
+
|
37
|
+
```
|
38
|
+
--disable-reek
|
39
|
+
--disable-rubocop
|
40
|
+
--disable-rbp
|
41
|
+
```
|
42
|
+
|
43
|
+
#### Warn only
|
44
|
+
Runs clint but still exists successfully, only printing the output
|
45
|
+
|
46
|
+
```
|
47
|
+
clint --warn
|
48
|
+
```
|
49
|
+
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
1. Fork it ( https://github.com/cloudspace/clint_eastwood/fork )
|
54
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
55
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
56
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
57
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/clint
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'clint_eastwood/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "clint_eastwood"
|
8
|
+
spec.version = ClintEastwood::VERSION
|
9
|
+
spec.authors = ["Joey Lorich"]
|
10
|
+
spec.email = ["joey@cloudspace.com"]
|
11
|
+
spec.summary = %q{The Cloudspace ruby linter}
|
12
|
+
spec.description = %q{A simple way to run a series of linting tools with default configurations matching cloudspace's best practices}
|
13
|
+
spec.homepage = "https://github.com/cloudspace/clint_eastwood"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency 'reek', '~> 1.3.7'
|
25
|
+
spec.add_dependency 'rubocop', '~> 0.23.0'
|
26
|
+
spec.add_dependency 'thor', '~> 0.19.1'
|
27
|
+
spec.add_dependency 'rails_best_practices', '~> 1.15.4'
|
28
|
+
|
29
|
+
spec.executables = ['clint']
|
30
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
AddModelVirtualAttributeCheck: { }
|
2
|
+
AlwaysAddDbIndexCheck: { }
|
3
|
+
#CheckSaveReturnValueCheck: { }
|
4
|
+
DefaultScopeIsEvilCheck: { }
|
5
|
+
DryBundlerInCapistranoCheck: { }
|
6
|
+
#HashSyntaxCheck: { }
|
7
|
+
IsolateSeedDataCheck: { }
|
8
|
+
KeepFindersOnTheirOwnModelCheck: { }
|
9
|
+
LawOfDemeterCheck: { }
|
10
|
+
#LongLineCheck: { max_line_length: 80 }
|
11
|
+
MoveCodeIntoControllerCheck: { }
|
12
|
+
MoveCodeIntoHelperCheck: { array_count: 3 }
|
13
|
+
MoveCodeIntoModelCheck: { use_count: 2 }
|
14
|
+
MoveFinderToNamedScopeCheck: { }
|
15
|
+
MoveModelLogicIntoModelCheck: { use_count: 4 }
|
16
|
+
NeedlessDeepNestingCheck: { nested_count: 2 }
|
17
|
+
NotRescueExceptionCheck: { }
|
18
|
+
NotUseDefaultRouteCheck: { }
|
19
|
+
NotUseTimeAgoInWordsCheck: { }
|
20
|
+
OveruseRouteCustomizationsCheck: { customize_count: 3 }
|
21
|
+
ProtectMassAssignmentCheck: { }
|
22
|
+
RemoveEmptyHelpersCheck: { }
|
23
|
+
#RemoveTabCheck: { }
|
24
|
+
#RemoveTrailingWhitespaceCheck: { }
|
25
|
+
RemoveUnusedMethodsInControllersCheck: { except_methods: [] }
|
26
|
+
RemoveUnusedMethodsInHelpersCheck: { except_methods: [] }
|
27
|
+
RemoveUnusedMethodsInModelsCheck: { except_methods: [] }
|
28
|
+
ReplaceComplexCreationWithFactoryMethodCheck: { attribute_assignment_count: 2 }
|
29
|
+
ReplaceInstanceVariableWithLocalVariableCheck: { }
|
30
|
+
RestrictAutoGeneratedRoutesCheck: { }
|
31
|
+
SimplifyRenderInControllersCheck: { }
|
32
|
+
SimplifyRenderInViewsCheck: { }
|
33
|
+
#UseBeforeFilterCheck: { customize_count: 2 }
|
34
|
+
UseModelAssociationCheck: { }
|
35
|
+
UseMultipartAlternativeAsContentTypeOfEmailCheck: { }
|
36
|
+
#UseParenthesesInMethodDefCheck: { }
|
37
|
+
UseObserverCheck: { }
|
38
|
+
UseQueryAttributeCheck: { }
|
39
|
+
UseSayWithTimeInMigrationsCheck: { }
|
40
|
+
UseScopeAccessCheck: { }
|
41
|
+
UseTurboSprocketsRails3Check: { }
|
data/config/reek.yml
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
Attribute:
|
2
|
+
enabled: false
|
3
|
+
exclude: []
|
4
|
+
BooleanParameter:
|
5
|
+
enabled: false
|
6
|
+
exclude: []
|
7
|
+
ClassVariable:
|
8
|
+
enabled: false
|
9
|
+
exclude: []
|
10
|
+
ControlParameter:
|
11
|
+
enabled: false
|
12
|
+
exclude: []
|
13
|
+
DataClump:
|
14
|
+
enabled: false
|
15
|
+
exclude: []
|
16
|
+
max_copies: 2
|
17
|
+
min_clump_size: 2
|
18
|
+
DuplicateMethodCall:
|
19
|
+
enabled: false
|
20
|
+
exclude: []
|
21
|
+
max_calls: 1
|
22
|
+
allow_calls: []
|
23
|
+
FeatureEnvy:
|
24
|
+
enabled: false
|
25
|
+
exclude: []
|
26
|
+
IrresponsibleModule:
|
27
|
+
enabled: false
|
28
|
+
exclude: []
|
29
|
+
LongParameterList:
|
30
|
+
enabled: false
|
31
|
+
exclude: []
|
32
|
+
max_params: 3
|
33
|
+
overrides:
|
34
|
+
initialize:
|
35
|
+
max_params: 5
|
36
|
+
LongYieldList:
|
37
|
+
enabled: false
|
38
|
+
exclude: []
|
39
|
+
max_params: 3
|
40
|
+
NestedIterators:
|
41
|
+
enabled: false
|
42
|
+
exclude: []
|
43
|
+
max_allowed_nesting: 1
|
44
|
+
ignore_iterators: []
|
45
|
+
NilCheck:
|
46
|
+
enabled: false
|
47
|
+
exclude: []
|
48
|
+
RepeatedConditional:
|
49
|
+
enabled: false
|
50
|
+
exclude: []
|
51
|
+
max_ifs: 2
|
52
|
+
TooManyInstanceVariables:
|
53
|
+
enabled: false
|
54
|
+
exclude: []
|
55
|
+
max_instance_variables: 9
|
56
|
+
TooManyMethods:
|
57
|
+
enabled: false
|
58
|
+
exclude: []
|
59
|
+
max_methods: 25
|
60
|
+
TooManyStatements:
|
61
|
+
enabled: true
|
62
|
+
max_statements: 7
|
63
|
+
UncommunicativeMethodName:
|
64
|
+
enabled: false
|
65
|
+
exclude: []
|
66
|
+
reject:
|
67
|
+
- !ruby/regexp /^[a-z]$/
|
68
|
+
- !ruby/regexp /[0-9]$/
|
69
|
+
- !ruby/regexp /[A-Z]/
|
70
|
+
accept: []
|
71
|
+
UncommunicativeModuleName:
|
72
|
+
enabled: false
|
73
|
+
exclude: []
|
74
|
+
reject:
|
75
|
+
- !ruby/regexp /^.$/
|
76
|
+
- !ruby/regexp /[0-9]$/
|
77
|
+
accept:
|
78
|
+
- Inline::C
|
79
|
+
UncommunicativeParameterName:
|
80
|
+
enabled: false
|
81
|
+
exclude: []
|
82
|
+
reject:
|
83
|
+
- !ruby/regexp /^.$/
|
84
|
+
- !ruby/regexp /[0-9]$/
|
85
|
+
- !ruby/regexp /[A-Z]/
|
86
|
+
accept: []
|
87
|
+
UncommunicativeVariableName:
|
88
|
+
enabled: false
|
89
|
+
exclude: []
|
90
|
+
reject:
|
91
|
+
- !ruby/regexp /^.$/
|
92
|
+
- !ruby/regexp /[0-9]$/
|
93
|
+
- !ruby/regexp /[A-Z]/
|
94
|
+
accept:
|
95
|
+
- _
|
96
|
+
UnusedParameters:
|
97
|
+
enabled: false
|
98
|
+
exclude: []
|
99
|
+
UtilityFunction:
|
100
|
+
enabled: false
|
101
|
+
exclude: []
|
102
|
+
max_helper_calls: 1
|
data/config/rubocop.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
EmptyLinesAroundBody:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
LineLength:
|
5
|
+
Max: 120
|
6
|
+
|
7
|
+
ClassLength:
|
8
|
+
Enabled: true
|
9
|
+
CountComments: false
|
10
|
+
Max: 150
|
11
|
+
|
12
|
+
MethodLength:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
WhileUntilModifier:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
ClassAndModuleChildren:
|
19
|
+
Enabled: false
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rails_best_practices/core/runner'
|
2
|
+
|
3
|
+
# Rails best practices
|
4
|
+
module RailsBestPractices
|
5
|
+
# RBP Core
|
6
|
+
module Core
|
7
|
+
#RBP Runner
|
8
|
+
class Runner
|
9
|
+
# initialize the runner.
|
10
|
+
#
|
11
|
+
# @param [Hash] options pass the prepares and reviews.
|
12
|
+
def initialize(options={})
|
13
|
+
gem_path = File.expand_path(File.dirname(__FILE__))
|
14
|
+
default_config_path = File.join(gem_path, '../config/rails_best_practices.yml')
|
15
|
+
|
16
|
+
custom_config = File.join(Runner.base_path, 'config/rails_best_practices.yml')
|
17
|
+
@config = File.exists?(custom_config) ? custom_config : default_config_path
|
18
|
+
|
19
|
+
lexicals = Array(options[:lexicals])
|
20
|
+
prepares = Array(options[:prepares])
|
21
|
+
reviews = Array(options[:reviews])
|
22
|
+
|
23
|
+
checks_loader = ChecksLoader.new(@config)
|
24
|
+
@lexicals = lexicals.empty? ? checks_loader.load_lexicals : lexicals
|
25
|
+
@prepares = prepares.empty? ? load_prepares : prepares
|
26
|
+
@reviews = reviews.empty? ? checks_loader.load_reviews : reviews
|
27
|
+
load_plugin_reviews if reviews.empty?
|
28
|
+
|
29
|
+
@lexical_checker ||= CodeAnalyzer::CheckingVisitor::Plain.new(checkers: @lexicals)
|
30
|
+
@plain_prepare_checker ||= CodeAnalyzer::CheckingVisitor::Plain.new(checkers: @prepares.select { |checker| checker.is_a? Prepares::GemfilePrepare })
|
31
|
+
@default_prepare_checker ||= CodeAnalyzer::CheckingVisitor::Default.new(checkers: @prepares.select { |checker| !checker.is_a? Prepares::GemfilePrepare })
|
32
|
+
@review_checker ||= CodeAnalyzer::CheckingVisitor::Default.new(checkers: @reviews)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/better_reek.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'reek/cli/application'
|
2
|
+
|
3
|
+
# Ignores log and WorkerError::log commands in the reek line count
|
4
|
+
class Reek::Core::CodeParser
|
5
|
+
def process_call(exp)
|
6
|
+
(exp.method_name == :log) &&
|
7
|
+
(!exp.receiver || exp.receiver.value == :WorkerError) &&
|
8
|
+
@element.count_statements(-1)
|
9
|
+
|
10
|
+
@element.record_call_to(exp)
|
11
|
+
process_default(exp)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'clint_eastwood'
|
3
|
+
|
4
|
+
# Clint Eastwood
|
5
|
+
module ClintEastwood
|
6
|
+
# Clint Eastwood command line interface
|
7
|
+
class CLI < Thor
|
8
|
+
option :path
|
9
|
+
option :lint, type: :array
|
10
|
+
option 'disable-rbp', type: :boolean
|
11
|
+
option 'disable-rubocop', type: :boolean
|
12
|
+
option 'disable-reek', type: :boolean
|
13
|
+
option 'warn', type: :boolean
|
14
|
+
|
15
|
+
default_task :lint
|
16
|
+
|
17
|
+
desc 'lint', 'Lints the given project directory'
|
18
|
+
def lint
|
19
|
+
clint = load_and_configure
|
20
|
+
|
21
|
+
# rubocop:disable Rails/Output
|
22
|
+
if clint.enforce
|
23
|
+
puts 'Project passed the linter successfully'
|
24
|
+
else
|
25
|
+
if options[:warn]
|
26
|
+
puts 'Linting Failed'
|
27
|
+
else
|
28
|
+
abort('Linting Failed')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
# rubocop:enable Rails/Output
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# Loads and configures clint
|
37
|
+
#
|
38
|
+
# @returns A configured ClintEastwood::TheEnforcer object
|
39
|
+
def load_and_configure
|
40
|
+
path = options[:path] || File.expand_path('.')
|
41
|
+
|
42
|
+
disable_rbp = options['disable-rbp'] || false
|
43
|
+
disable_rubocop = options['disable-rubocop'] || false
|
44
|
+
disable_reek = options['disable-reek'] || false
|
45
|
+
|
46
|
+
ClintEastwood::TheEnforcer.new(
|
47
|
+
path,
|
48
|
+
lint: options[:lint],
|
49
|
+
disable_rbp: disable_rbp,
|
50
|
+
disable_rubocop: disable_rubocop,
|
51
|
+
disable_reek: disable_reek
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'clint_eastwood/version'
|
2
|
+
require 'rails_best_practices'
|
3
|
+
require_relative 'better_reek.rb'
|
4
|
+
require_relative 'better_rails_best_practices.rb'
|
5
|
+
|
6
|
+
# Clint Eastwood
|
7
|
+
module ClintEastwood
|
8
|
+
|
9
|
+
# Lint enforcer
|
10
|
+
class TheEnforcer
|
11
|
+
@result = true
|
12
|
+
|
13
|
+
# Initializes a new Enforce Object with the desired settings
|
14
|
+
#
|
15
|
+
# @param path [String] The base path to lint
|
16
|
+
# @param lint [Array<String>] The desired subdirectories to lint (defaults to ['app', 'lib', 'config', 'spec'])
|
17
|
+
# @param disable_reek [Boolean] If true, this stops reek from running
|
18
|
+
# @param disable_rubocop [Boolean] If true, this stops rubocop from running
|
19
|
+
# @param disable_rbp [Boolean] If true, this stops rails best practices from running
|
20
|
+
#
|
21
|
+
# @returns [TheEnforcer] A new enforcer object
|
22
|
+
def initialize(path, lint: nil, disable_reek: false, disable_rubocop: false, disable_rbp: false)
|
23
|
+
gem_path = File.expand_path(File.dirname(__FILE__))
|
24
|
+
@config_path = File.join(gem_path, '../config')
|
25
|
+
|
26
|
+
@disable_rubocop = disable_rubocop
|
27
|
+
@disable_reek = disable_reek
|
28
|
+
@disable_rbp = disable_rbp
|
29
|
+
|
30
|
+
@base_path = path
|
31
|
+
@lint_paths = lint || %w(app lib config spec)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Runs each desired linting gem with the appropriate settings
|
35
|
+
# @returns [Boolean] Whether or not the linters were all successfuls
|
36
|
+
def enforce
|
37
|
+
reek_result = @disable_reek || reek
|
38
|
+
rubocop_result = @disable_rubocop || rubocop
|
39
|
+
rbp_result = @disable_rbp || rails_best_practices
|
40
|
+
|
41
|
+
reek_result && rubocop_result && rbp_result
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def locate_config(filename)
|
47
|
+
@user_config = File.join(@base_path, 'config', filename)
|
48
|
+
@default_config = File.join(@config_path, filename)
|
49
|
+
|
50
|
+
File.exist?(@user_config) ? @user_config : @default_config
|
51
|
+
end
|
52
|
+
|
53
|
+
# Run reek
|
54
|
+
def reek
|
55
|
+
@reek_config = locate_config('reek.yml')
|
56
|
+
|
57
|
+
reek_command = []
|
58
|
+
|
59
|
+
@lint_paths.each do |path|
|
60
|
+
reek_command << File.join(@base_path, path)
|
61
|
+
end
|
62
|
+
|
63
|
+
reek_command.concat ['--config', "#{@reek_config}"]
|
64
|
+
|
65
|
+
# Reek returns the number of errors, so make sure it's zero
|
66
|
+
Reek::Cli::Application.new(reek_command).execute == 0
|
67
|
+
end
|
68
|
+
|
69
|
+
# Run rubocop
|
70
|
+
def rubocop
|
71
|
+
@rubocop_config = locate_config('rubocop.yml')
|
72
|
+
|
73
|
+
paths = @lint_paths.map { |p| File.join(@base_path, p) }.join(' ')
|
74
|
+
|
75
|
+
system "bundle exec rubocop --rails --config #{@rubocop_config} #{paths}"
|
76
|
+
end
|
77
|
+
|
78
|
+
# Run rails best practices
|
79
|
+
def rails_best_practices
|
80
|
+
options = {}
|
81
|
+
analyzer = RailsBestPractices::Analyzer.new(@base_path)
|
82
|
+
analyzer.analyze
|
83
|
+
analyzer.output
|
84
|
+
analyzer.runner.errors.size == 0
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: clint_eastwood
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joey Lorich
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: reek
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.7
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.7
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.23.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.23.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: thor
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.19.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.19.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rails_best_practices
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.15.4
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.15.4
|
97
|
+
description: A simple way to run a series of linting tools with default configurations
|
98
|
+
matching cloudspace's best practices
|
99
|
+
email:
|
100
|
+
- joey@cloudspace.com
|
101
|
+
executables:
|
102
|
+
- clint
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- .gitignore
|
107
|
+
- Gemfile
|
108
|
+
- Gemfile.lock
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- bin/clint
|
113
|
+
- clint_eastwood.gemspec
|
114
|
+
- config/rails_best_practices.yml
|
115
|
+
- config/reek.yml
|
116
|
+
- config/rubocop.yml
|
117
|
+
- lib/better_rails_best_practices.rb
|
118
|
+
- lib/better_reek.rb
|
119
|
+
- lib/clint_eastwood.rb
|
120
|
+
- lib/clint_eastwood/cli.rb
|
121
|
+
- lib/clint_eastwood/version.rb
|
122
|
+
homepage: https://github.com/cloudspace/clint_eastwood
|
123
|
+
licenses:
|
124
|
+
- MIT
|
125
|
+
metadata: {}
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 2.0.14
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: The Cloudspace ruby linter
|
146
|
+
test_files: []
|