rubocop-stylecheck 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c60afe33c5f252769bbea51bd2c8c9ecdb47e8be
4
+ data.tar.gz: 1c09ae96a90854d746a4a102cea99efc84c1f57e
5
+ SHA512:
6
+ metadata.gz: 73cf744a8d92c1620a645ae453095c9c6fe905ff7c0edac328044c33dc890d26c97156999ea9c464df770c24d149fc27a978ff4bd2054e88a9ab179d1f2008a9
7
+ data.tar.gz: ab53f6e1d5994b6b32adcc369175ee050bbb76490e4adf81018abc2bed2ede01a86811c9c457b7f80f33725b367a4eccf2a2235f2abd862f37a1cf2a4eb456c1
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ /.bundle/
2
+ /Gemfile.lock
3
+ /pkg/
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rubocop-stylecheck.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Krzysztof Wawer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # Rubocop::Stylecheck
2
+
3
+ This gem is inspired by `ragnarson-stylecheck` gem.
4
+
5
+ This gem adds rake tasks which easily can invoke RuboCop with predefined options. You can use it in Ruby on Rails projects (with dedicated support from RuboCop side), but you can also use it in projects without Ruby on Rails - this gem supports both cases.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem "rubocop-stylecheck"
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install rubocop-stylecheck
22
+
23
+ After all in Rakefile you must add:
24
+
25
+ ```ruby
26
+ require "rubocop/stylecheck/rake_task"
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ Available rake tasks:
32
+ * style - shortcut for style:rubocop:with_auto_correct
33
+ * style:rubocop:with_auto_correct - run RuboCop with auto correction
34
+ * style:rubocop:without_auto_correct - run RuboCop without auto correction
35
+ * style:rubocop:generate_local_config - generate rubocop config locally, if we want to override something
36
+
37
+ For generating local config file you must set:
38
+ ```ruby
39
+ Rubocop::Stylecheck.config_path = "..."
40
+ ```
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/alterans/rubocop-stylecheck.
45
+
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
50
+
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler"
2
+ require "bundler/gem_tasks"
3
+ Bundler.require
4
+
5
+ require "rubocop/stylecheck/rake_task"
@@ -0,0 +1 @@
1
+ require "rubocop/stylecheck"
@@ -0,0 +1,16 @@
1
+ require "rubocop/stylecheck/version"
2
+
3
+ module Rubocop
4
+ module Stylecheck
5
+ class << self
6
+ attr_accessor :config_path
7
+
8
+ def project_config_path
9
+ File.join(Dir.pwd, ".rubocop.yml")
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ require "rubocop/stylecheck/cli"
16
+ require "rubocop/stylecheck/railtie" if defined?(Rails)
@@ -0,0 +1,21 @@
1
+ module Rubocop
2
+ module Stylecheck
3
+ module Cli
4
+ class << self
5
+ def options
6
+ options = ["--fail-level", "refactor"]
7
+ options += ["--rails"] if defined?(Rails)
8
+ options
9
+ end
10
+
11
+ def options_with_auto_correct
12
+ options + ["--auto-correct"]
13
+ end
14
+
15
+ def options_with_cop
16
+ options + ["--display-cop-names"]
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,10 @@
1
+ module Rubocop
2
+ module Stylecheck
3
+ class Railtie < Rails::Railtie
4
+ rake_tasks do
5
+ rake_path = File.join(File.dirname(__FILE__), "tasks/*.rake")
6
+ Dir[rake_path].each { |f| load f }
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,2 @@
1
+ require "rake"
2
+ load "rubocop/stylecheck/tasks/rubocop.rake"
@@ -0,0 +1,39 @@
1
+ require "rubocop/stylecheck"
2
+ require "fileutils"
3
+
4
+ def run(options)
5
+ sh "bundle exec rubocop #{options.join(' ')}" do |ok, _res|
6
+ abort "Fix code style errors" unless ok
7
+ end
8
+ end
9
+
10
+ namespace :style do
11
+ namespace :rubocop do
12
+ desc "Run RuboCop with auto_correct"
13
+ task :with_auto_correct do
14
+ run(Rubocop::Stylecheck::Cli.options_with_auto_correct)
15
+ end
16
+
17
+ desc "Run RuboCop without auto_correct"
18
+ task :without_auto_correct do
19
+ run(Rubocop::Stylecheck::Cli.options_with_cop)
20
+ end
21
+
22
+ desc "Generate local RuboCop config"
23
+ task :generate_local_config do
24
+ template_config_path = Rubocop::Stylecheck.config_path
25
+ project_config_path = Rubocop::Stylecheck.project_config_path
26
+
27
+ if template_config_path && File.exist?(template_config_path)
28
+ FileUtils.cp(template_config_path, project_config_path)
29
+ else
30
+ abort "Config file doesn't exist, please use Robocop::Stylecheck.config_path = ..."
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ desc "Check codestyle and fix common errors"
37
+ task :style do
38
+ Rake::Task["style:rubocop:with_auto_correct"].invoke
39
+ end
@@ -0,0 +1,5 @@
1
+ module Rubocop
2
+ module Stylecheck
3
+ VERSION = "0.1.0".freeze
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "rubocop/stylecheck/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rubocop-stylecheck"
7
+ spec.version = Rubocop::Stylecheck::VERSION
8
+ spec.authors = ["Krzysztof Wawer"]
9
+ spec.email = ["krzysztof.wawer@gmail.com"]
10
+
11
+ spec.summary = "Automatic style check for ruby projects"
12
+ spec.description = "Adds rake tasks for checking ruby style"
13
+ spec.homepage = "https://github.com/alterans/rubocop-stylecheck"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.14"
24
+ spec.add_dependency "rake", "~> 10.0"
25
+ spec.add_dependency "rubocop", "~> 0.51"
26
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubocop-stylecheck
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Krzysztof Wawer
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-11-04 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.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.51'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.51'
55
+ description: Adds rake tasks for checking ruby style
56
+ email:
57
+ - krzysztof.wawer@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rubocop.yml"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - lib/rubocop-stylecheck.rb
69
+ - lib/rubocop/stylecheck.rb
70
+ - lib/rubocop/stylecheck/cli.rb
71
+ - lib/rubocop/stylecheck/railtie.rb
72
+ - lib/rubocop/stylecheck/rake_task.rb
73
+ - lib/rubocop/stylecheck/tasks/rubocop.rake
74
+ - lib/rubocop/stylecheck/version.rb
75
+ - rubocop-stylecheck.gemspec
76
+ homepage: https://github.com/alterans/rubocop-stylecheck
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.6.11
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Automatic style check for ruby projects
100
+ test_files: []