quipper-rubocop-config 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: 39849ee3faaf88c0150a90c7205f44c5c2d711f0
4
+ data.tar.gz: 8f4662baa1e1233a65a8b96e81f1229b2fef081d
5
+ SHA512:
6
+ metadata.gz: 2eb33470f7f7e94e1877ee1a9b8351ff0aa5f3cfb126d980a7d35a87df02a455be9aa2c75cec09e0f3aa8ae1f344bc861fbfe210cb40fc983a40fa4f66ca57a2
7
+ data.tar.gz: 8731b6aadd1682ee0f8d3116d7fc855957c624682bb3c6cb30d65c79bfc210a6814f9987f520dadd35d9de72e9373a975f6878c8c0f00f500aad509cf277e5ac
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ # This file is autogenerated by quipper-rubocop-config gem.
4
+ #
5
+ # If you would like to change a rubocop rule please do so here:
6
+ # https://github.com/quipper/quipper-rubocop-config/blob/master/config/rubocop.yml
7
+ # This ensures the rubocop config will be applied across all repos using the gem.
8
+ inherit_gem:
9
+ quipper-rubocop-config:
10
+ - "config/rubocop.yml"
11
+
12
+ AllCops:
13
+ TargetRubyVersion: 2.5
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,59 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2018-07-11 18:46:26 +0900 using RuboCop version 0.58.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Cop supports --auto-correct.
11
+ # Configuration parameters: AllowBorderComment, AllowMarginComment.
12
+ Layout/EmptyComment:
13
+ Exclude:
14
+ - 'exe/quipper-rubocop-config'
15
+
16
+ # Offense count: 1
17
+ # Cop supports --auto-correct.
18
+ Layout/LeadingBlankLines:
19
+ Exclude:
20
+ - 'quipper-rubocop-config.gemspec'
21
+
22
+ # Offense count: 1
23
+ # Cop supports --auto-correct.
24
+ Layout/LeadingCommentSpace:
25
+ Exclude:
26
+ - 'lib/quipper/rubocop/config.rb'
27
+
28
+ # Offense count: 1
29
+ Style/Documentation:
30
+ Exclude:
31
+ - 'spec/**/*'
32
+ - 'test/**/*'
33
+ - 'lib/quipper/rubocop/config.rb'
34
+
35
+ # Offense count: 1
36
+ # Cop supports --auto-correct.
37
+ Style/ExpandPathArguments:
38
+ Exclude:
39
+ - 'quipper-rubocop-config.gemspec'
40
+
41
+ # Offense count: 1
42
+ # Configuration parameters: MinBodyLength.
43
+ Style/GuardClause:
44
+ Exclude:
45
+ - 'lib/quipper/rubocop/config.rb'
46
+
47
+ # Offense count: 1
48
+ # Cop supports --auto-correct.
49
+ # Configuration parameters: EnforcedOctalStyle.
50
+ # SupportedOctalStyles: zero_with_o, zero_only
51
+ Style/NumericLiteralPrefix:
52
+ Exclude:
53
+ - 'lib/quipper/rubocop/config.rb'
54
+
55
+ # Offense count: 6
56
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
57
+ # URISchemes: http, https
58
+ Metrics/LineLength:
59
+ Max: 120
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in quipper-rubocop-config.gemspec
8
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Drew Terry
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,53 @@
1
+ # Quipper Rubocop Configs
2
+
3
+ Adds Rubocop and holds the default rubocop config for Quipper that can be shared in any ruby repo.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ quipper_gem 'quipper-rubocop-config'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ `$ bundle install`
16
+
17
+ $$ Usage
18
+
19
+ Then using the command line client you can use:
20
+
21
+ `$ bundle exec quipper-rubocop-config install`
22
+
23
+ Which will automatically install the `.rubocop.yml` which holds the configs.
24
+
25
+
26
+ ### Adding it into a legacy application
27
+
28
+ Additionally if this is being installed into a legacy repo or one that already has a lot of files (and thus rubocop errors) you can run:
29
+
30
+ `$ bundle exec quipper-rubocop-config --with_todo`
31
+
32
+ This installs the `.rubocop_todo.yml` file which lists the rules that are currently broken but which you might want to fix later and tells rubocop to ignore them for now.
33
+
34
+ ## Prepush hook
35
+
36
+ If you want to run rubocop before pushing there is a prepush hook which you can install.
37
+
38
+ `$ bundle exec quipper-rubocop-config install_prepush`
39
+
40
+ This installs a prepush in `.git/hooks` folder so if you already have a `pre-push` file you won't be able to use it.
41
+ If you want the fancy ability to autocorrect and commit your changes as well you can set `export RUBO_AUTOCORRECT=true` as an environment variable.
42
+
43
+ ## Changing or adding a rule
44
+ Please edit this file:
45
+
46
+ https://github.com/quipper/quipper-rubocop-config/blob/master/config/rubocop.yml
47
+
48
+ ## Uninstall
49
+
50
+ To remove this gem and all created files simply run:
51
+ `$ bundle exec quipper-rubocop-config uninstall`
52
+
53
+ and then remove the Gem from your Gemfile.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "quipper/rubocop/config"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,24 @@
1
+ Style/StringLiterals:
2
+ EnforcedStyle: double_quotes
3
+ Enabled: true
4
+
5
+ Layout/DotPosition:
6
+ EnforcedStyle: leading
7
+ Enabled: true
8
+
9
+ Layout/SpaceInsideHashLiteralBraces:
10
+ EnforcedStyle: space
11
+ Enabled: true
12
+
13
+ Style/AsciiComments:
14
+ Enabled: false
15
+
16
+ Metrics/BlockLength:
17
+ Exclude:
18
+ - "spec/**/*.rb"
19
+
20
+ Style/NumericPredicate:
21
+ Enabled: false
22
+
23
+ Naming/PredicateName:
24
+ Enabled: false
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ $LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
6
+
7
+ # Exit cleanly from an early interrupt
8
+ Signal.trap("INT") { exit 1 }
9
+
10
+ require "quipper/rubocop/config"
11
+
12
+ Quipper::Rubocop::Config::CLI.start(ARGV)
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+ require "erb"
5
+
6
+ module Quipper
7
+ module Rubocop
8
+ module Config
9
+ class CLI < Thor
10
+ RUBOCOP_CONFIG_FILE_NAME = ".rubocop.yml"
11
+ RUBOCOP_TODO_FILE_NAME = ".rubocop_todo.yml"
12
+ GITHOOK_FILE_PATH = ".git/hooks/pre-push"
13
+
14
+ desc "install", "Install rubocop config"
15
+ option :with_todo
16
+ def install
17
+ create_rubocop_config!(RUBOCOP_CONFIG_FILE_NAME)
18
+ create_rubocop_todo_file! if options[:with_todo]
19
+ end
20
+
21
+ desc "install_prepush", "Install prepush hook"
22
+ def install_prepush
23
+ create_prepush_hook!(GITHOOK_FILE_PATH)
24
+ end
25
+
26
+ desc "uninstall", "uninstall rubocop config"
27
+ option :hook
28
+ def uninstall
29
+ remove_file(RUBOCOP_CONFIG_FILE_NAME) unless options[:hook]
30
+ remove_file(RUBOCOP_TODO_FILE_NAME) unless options[:hook]
31
+ remove_file(GITHOOK_FILE_PATH)
32
+
33
+ puts "Uninstallation complete"
34
+ end
35
+
36
+ private
37
+
38
+ def create_rubocop_config!(config_file_name)
39
+ puts "#{File.exist?(config_file_name) ? 'overwrite' : 'create'} #{config_file_name}"
40
+ FileUtils.copy_file(File.join(template_path, config_file_name), config_file_name)
41
+ end
42
+
43
+ def create_rubocop_todo_file!
44
+ puts "creating rubocop todo file"
45
+ system "rubocop --auto-gen-config"
46
+ end
47
+
48
+ def create_prepush_hook!(file_path)
49
+ puts "adding git prepush hook at #{file_path}"
50
+
51
+ raise "File already exists at #{file_path}" if File.exist?(file_path)
52
+
53
+ hook_template = File.join(template_path, ".githooks/pre-push.erb")
54
+ @branch_name = ask("What is the name of the branch you would like to compare to? (usually master or develop)")
55
+ hook_template = ERB.new(File.read(hook_template)).result(binding)
56
+ File.open(file_path, "w+") do |f|
57
+ f.write(hook_template)
58
+ end
59
+ FileUtils.chmod(0755, file_path)
60
+ puts "hook created!"
61
+ end
62
+
63
+ def remove_file(file_path)
64
+ if File.exist?(file_path) && added_by_this_gem?(file_path)
65
+ File.delete(file_path)
66
+ puts "Removing #{file_path}"
67
+ end
68
+ end
69
+
70
+ def template_path
71
+ File.expand_path("../../../templates", __dir__)
72
+ end
73
+
74
+ def added_by_this_gem?(file_name)
75
+ File.read(file_name).include?("quipper-rubocop-config")
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Quipper
4
+ module Rubocop
5
+ module Config
6
+ VERSION = "0.1.0"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "quipper/rubocop/config/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "quipper-rubocop-config"
9
+ spec.version = Quipper::Rubocop::Config::VERSION
10
+ spec.authors = ["Drew Terry"]
11
+ spec.email = ["drewpterry@yahoo.com"]
12
+
13
+ spec.summary = "Quipper's rubocop config"
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_dependency "rubocop", "0.58.1" # Rubocop doesn't follow semantic versioning and is relatively unstable
24
+ spec.add_dependency "thor", "~> 0.19"
25
+ spec.add_development_dependency "bundler", "~> 1.15"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ end
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Automatically generated by quipper-rubocop-config
4
+
5
+ all_changed_files="git diff --name-only <%= @branch_name %>... | grep '\.rb$'"
6
+ autocorrect_command="$all_changed_files | xargs bundle exec rubocop -a"
7
+ normal_rubocop_command="$all_changed_files | xargs bundle exec rubocop"
8
+
9
+ printf "\nFiles to be checked...\n\n"
10
+
11
+ eval $all_changed_files
12
+
13
+ if [ "$RUBO_AUTOCORRECT" = true ]; then
14
+ if [ -z "$(git status --untracked-files=no --porcelain)" ]; then
15
+
16
+ printf "\nFixing style mistakes in changed files...\n\n"
17
+
18
+ eval $autocorrect_command
19
+
20
+ printf "\n"
21
+
22
+ git add -u
23
+ git commit -m "automated rubocop changes"
24
+
25
+ else
26
+ printf "Your working directory isn't clean, please commit or stash the files in your working directory"
27
+ printf "\n\n"
28
+ exit 1
29
+ fi
30
+
31
+ else
32
+ printf "\nRunning without autocorrect"
33
+ printf "\nIf you want to run autocorrect you can use the following command (it's long!) and commit the changes yourself:\n\n"
34
+ printf "$autocorrect_command"
35
+ fi
36
+
37
+ printf "\n\nChecking modified lines for mistakes...\n\n"
38
+
39
+ eval $normal_rubocop_command
@@ -0,0 +1,11 @@
1
+ # This file is autogenerated by quipper-rubocop-config gem.
2
+ #
3
+ # If you would like to change a rubocop rule please do so here:
4
+ # https://github.com/quipper/quipper-rubocop-config/blob/master/config/rubocop.yml
5
+ # This ensures the rubocop config will be applied across all repos using the gem.
6
+ inherit_gem:
7
+ quipper-rubocop-config:
8
+ - "config/rubocop.yml"
9
+
10
+ AllCops:
11
+ TargetRubyVersion: 2.5
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quipper-rubocop-config
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Drew Terry
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-08-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubocop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.58.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.58.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.19'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.19'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.15'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.15'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description:
70
+ email:
71
+ - drewpterry@yahoo.com
72
+ executables:
73
+ - quipper-rubocop-config
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rubocop.yml"
79
+ - ".rubocop_todo.yml"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - config/rubocop.yml
87
+ - exe/quipper-rubocop-config
88
+ - lib/quipper/rubocop/config.rb
89
+ - lib/quipper/rubocop/config/version.rb
90
+ - quipper-rubocop-config.gemspec
91
+ - templates/.githooks/pre-push.erb
92
+ - templates/.rubocop.yml
93
+ homepage:
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.5.2
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Quipper's rubocop config
117
+ test_files: []