code_quality_check 0.1.5 → 0.1.8
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 +4 -4
- data/lib/code_quality_check/version.rb +1 -1
- data/lib/code_quality_check.rb +6 -0
- data/lib/generators/code_quality_check/install_generator.rb +21 -2
- data/lib/generators/code_quality_check/templates/{overcommit.rb → code_quality_check.rb} +17 -1
- data/lib/generators/code_quality_check/templates/overcommit.yml +47 -11
- data/lib/generators/code_quality_check/templates/post-checkout +125 -0
- data/lib/generators/code_quality_check/templates/pre-commit +125 -0
- data/lib/generators/code_quality_check/uninstall_generator.rb +8 -2
- metadata +51 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0db4bd2bc7348adfe3bbd706fba3b0d079d8ac50d889ce58bb616506145b43f5
|
|
4
|
+
data.tar.gz: 162015c6573caf0aed76c5c54c514db53454ecbb55013642c2c9c35fad541955
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2a5b7282e7702df72d7846d30a7c20836012158362a37d15f106410a8e522447752cec77cc82dac18f105ca2413ac6978135d54b3ec880f0ea66d786e7484a7b
|
|
7
|
+
data.tar.gz: 69c14673a15f335936e3c98e83271ad72ed972a44a0b50b0e479f090fbd367654e7a9709e731af547a5c92f408dd52d5fe3916af3813034ccc42b22cdc1ea595
|
data/lib/code_quality_check.rb
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative 'code_quality_check/version'
|
|
4
|
+
|
|
5
|
+
# CodeQualityCheck integrates RuboCop, Brakeman, and Rails Best Practices
|
|
6
|
+
# with Overcommit to enforce automated code quality checks on every Git commit.
|
|
7
|
+
#
|
|
8
|
+
# @see https://github.com/aniruddhami/code_quality_check
|
|
4
9
|
module CodeQualityCheck
|
|
10
|
+
# Base error class for CodeQualityCheck gem.
|
|
5
11
|
class Error < StandardError; end
|
|
6
12
|
end
|
|
@@ -4,21 +4,40 @@ require 'rails/generators/base'
|
|
|
4
4
|
|
|
5
5
|
module CodeQualityCheck
|
|
6
6
|
module Generators
|
|
7
|
-
#
|
|
7
|
+
# Rails generator that installs Overcommit, RuboCop, Brakeman, and Rails Best
|
|
8
|
+
# Practices configuration files into a Rails project.
|
|
9
|
+
#
|
|
10
|
+
# Run with: +rails generate code_quality_check:install+
|
|
11
|
+
#
|
|
12
|
+
# Creates:
|
|
13
|
+
# - config/initializers/code_quality_check.rb
|
|
14
|
+
# - .overcommit.yml
|
|
15
|
+
# - .rubocop.yml
|
|
16
|
+
# - .git/hooks/pre-commit
|
|
17
|
+
# - .git/hooks/post-checkout
|
|
8
18
|
class InstallGenerator < Rails::Generators::Base
|
|
9
19
|
source_root File.expand_path('templates', __dir__)
|
|
10
20
|
desc 'This generator creates an initializer file for Overcommit'
|
|
11
21
|
|
|
22
|
+
def install_overcommit
|
|
23
|
+
# Install Overcommit
|
|
24
|
+
run 'bundle exec overcommit --install'
|
|
25
|
+
end
|
|
26
|
+
|
|
12
27
|
# Define a method that copies the initializer file to the config/initializers directory
|
|
13
28
|
def copy_required_files
|
|
14
29
|
# Copy the initializer file to the config/initializers directory
|
|
15
|
-
template '
|
|
30
|
+
template 'code_quality_check.rb', 'config/initializers/code_quality_check.rb'
|
|
16
31
|
|
|
17
32
|
# Copy the Overcommit configuration file to the root directory
|
|
18
33
|
template 'overcommit.yml', '.overcommit.yml'
|
|
19
34
|
|
|
20
35
|
# Copy the RuboCop configuration file to the root directory
|
|
21
36
|
template 'rubocop.yml', '.rubocop.yml'
|
|
37
|
+
|
|
38
|
+
# Copy the pre-commit hook to the .git/hooks directory
|
|
39
|
+
template 'pre-commit', '.git/hooks/pre-commit', force: true
|
|
40
|
+
template 'post-checkout', '.git/hooks/post-checkout', force: true
|
|
22
41
|
end
|
|
23
42
|
end
|
|
24
43
|
end
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
# config/initializers/
|
|
1
|
+
# config/initializers/code_quality_check.rb
|
|
2
|
+
|
|
3
|
+
# Ensure code_quality_check gem is installed before setting up hooks
|
|
4
|
+
begin
|
|
5
|
+
Gem::Specification.find_by_name('code_quality_check')
|
|
6
|
+
rescue Gem::MissingSpecError
|
|
7
|
+
raise <<~MSG
|
|
8
|
+
The code_quality_check gem is not installed.
|
|
9
|
+
|
|
10
|
+
Add to your Gemfile:
|
|
11
|
+
gem 'code_quality_check'
|
|
12
|
+
|
|
13
|
+
Then run:
|
|
14
|
+
bundle install
|
|
15
|
+
rails generate code_quality_check:install
|
|
16
|
+
MSG
|
|
17
|
+
end
|
|
2
18
|
|
|
3
19
|
if Rails.env.development? || Rails.env.test?
|
|
4
20
|
begin
|
|
@@ -2,18 +2,21 @@
|
|
|
2
2
|
# extend the default configuration defined in:
|
|
3
3
|
# https://github.com/sds/overcommit/blob/master/config/default.yml
|
|
4
4
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
5
|
+
# Required gems (add to your Gemfile; code_quality_check provides most):
|
|
6
|
+
# - overcommit
|
|
7
|
+
# - rubocop, rubocop-performance, rubocop-rails
|
|
8
|
+
# - brakeman
|
|
9
|
+
# - rails_best_practices
|
|
10
|
+
# - bundler-audit (for BundleAudit security check)
|
|
11
|
+
#
|
|
12
|
+
# Optional code quality gems (enable hooks below to use):
|
|
13
|
+
# - reek (code smells)
|
|
14
|
+
# - flay (code duplication)
|
|
15
|
+
# - fasterer (performance)
|
|
9
16
|
#
|
|
10
17
|
# For a complete list of hooks, see:
|
|
11
18
|
# https://github.com/sds/overcommit/tree/master/lib/overcommit/hook
|
|
12
|
-
|
|
13
|
-
# For a complete list of options that you can use to customize hooks, see:
|
|
14
|
-
# https://github.com/sds/overcommit#configuration
|
|
15
|
-
#
|
|
16
|
-
# Uncomment the following lines to make the configuration take effect.
|
|
19
|
+
#-------------------------------------------------------------------------------
|
|
17
20
|
|
|
18
21
|
PreCommit:
|
|
19
22
|
RuboCop:
|
|
@@ -38,10 +41,43 @@ PreCommit:
|
|
|
38
41
|
# Brakeman is a static analysis security vulnerability scanner for Ruby on Rails applications.
|
|
39
42
|
Brakeman:
|
|
40
43
|
enabled: true
|
|
41
|
-
|
|
44
|
+
required_executable: 'brakeman'
|
|
45
|
+
command: ['bundle', 'exec', 'brakeman', '--skip-libs', '-w3']
|
|
46
|
+
description: 'Scanning for security vulnerabilities with Brakeman'
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
# BundleAudit checks Gemfile.lock for known vulnerable gem versions (CVE database).
|
|
49
|
+
BundleAudit:
|
|
50
|
+
enabled: true
|
|
51
|
+
required_executable: 'bundle-audit'
|
|
52
|
+
description: 'Checking for vulnerable gem versions'
|
|
53
|
+
include:
|
|
54
|
+
- 'Gemfile.lock'
|
|
55
|
+
|
|
56
|
+
# Reek analyzes Ruby code for code smells (add gem 'reek' to enable).
|
|
57
|
+
Reek:
|
|
44
58
|
enabled: false
|
|
59
|
+
required_executable: 'reek'
|
|
60
|
+
description: 'Detecting code smells with Reek'
|
|
61
|
+
flags: ['--single-line', '--no-color', '--force-exclusion']
|
|
62
|
+
include: '**/*.rb'
|
|
63
|
+
|
|
64
|
+
# Flay finds structural code duplication (add gem 'flay' to enable).
|
|
65
|
+
Flay:
|
|
66
|
+
enabled: false
|
|
67
|
+
required_executable: 'flay'
|
|
68
|
+
description: 'Finding code duplication with Flay'
|
|
69
|
+
mass_threshold: 16
|
|
70
|
+
include: '**/*.rb'
|
|
71
|
+
|
|
72
|
+
# Fasterer suggests Ruby performance improvements (add gem 'fasterer' to enable).
|
|
73
|
+
Fasterer:
|
|
74
|
+
enabled: false
|
|
75
|
+
required_executable: 'fasterer'
|
|
76
|
+
description: 'Analyzing for potential speed improvements'
|
|
77
|
+
include: '**/*.rb'
|
|
78
|
+
|
|
79
|
+
TrailingWhitespace:
|
|
80
|
+
enabled: true
|
|
45
81
|
exclude:
|
|
46
82
|
- '**/lib/**/*' # Ignore trailing whitespace in generated files
|
|
47
83
|
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# Entrypoint for Overcommit hook integration. Installing Overcommit will result
|
|
5
|
+
# in all of your git hooks being copied from this file, allowing the framework
|
|
6
|
+
# to manage your hooks for you.
|
|
7
|
+
|
|
8
|
+
# Prevent a Ruby stack trace from appearing when we interrupt the hook.
|
|
9
|
+
# Note that this will be overridden when Overcommit is loaded, since the
|
|
10
|
+
# InterruptHandler will redefine the trap at that time.
|
|
11
|
+
Signal.trap('INT') do
|
|
12
|
+
puts 'Hook run interrupted'
|
|
13
|
+
exit 130
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Allow hooks to be disabled via environment variable so git commands can be run
|
|
17
|
+
# in scripts without Overcommit running hooks
|
|
18
|
+
if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
|
|
19
|
+
exit
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
hook_type = File.basename($0)
|
|
23
|
+
if hook_type == 'overcommit-hook'
|
|
24
|
+
puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \
|
|
25
|
+
"by each hook in a repository's .git/hooks directory."
|
|
26
|
+
exit 64 # EX_USAGE
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Check if Overcommit should invoke a Bundler context for loading gems
|
|
30
|
+
require 'yaml'
|
|
31
|
+
# rubocop:disable Style/RescueModifier
|
|
32
|
+
gemfile =
|
|
33
|
+
begin
|
|
34
|
+
YAML.load_file('.overcommit.yml', aliases: true)['gemfile']
|
|
35
|
+
rescue ArgumentError
|
|
36
|
+
YAML.load_file('.overcommit.yml')['gemfile']
|
|
37
|
+
end rescue nil
|
|
38
|
+
|
|
39
|
+
if gemfile
|
|
40
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
|
41
|
+
require 'bundler'
|
|
42
|
+
|
|
43
|
+
begin
|
|
44
|
+
Bundler.setup
|
|
45
|
+
rescue Bundler::BundlerError => e
|
|
46
|
+
puts "Problem loading '#{gemfile}': #{e.message}"
|
|
47
|
+
puts "Try running:\nbundle install --gemfile=#{gemfile}" if e.is_a?(Bundler::GemNotFound)
|
|
48
|
+
exit 78 # EX_CONFIG
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
# rubocop:enable Style/RescueModifier
|
|
52
|
+
|
|
53
|
+
begin
|
|
54
|
+
require 'overcommit'
|
|
55
|
+
puts 'Signing Overcommit hooks...'
|
|
56
|
+
exec('overcommit --sign')
|
|
57
|
+
rescue LoadError
|
|
58
|
+
if gemfile
|
|
59
|
+
puts 'You have specified the `gemfile` option in your Overcommit ' \
|
|
60
|
+
'configuration but have not added the `overcommit` gem to ' \
|
|
61
|
+
"#{gemfile}."
|
|
62
|
+
else
|
|
63
|
+
puts 'This repository contains hooks installed by Overcommit, but the ' \
|
|
64
|
+
"`overcommit` gem is not installed.\n" \
|
|
65
|
+
'Install it with `gem install overcommit`.'
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
exit 64 # EX_USAGE
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
begin
|
|
72
|
+
logger = Overcommit::Logger.new(STDOUT)
|
|
73
|
+
Overcommit::Utils.log = logger
|
|
74
|
+
|
|
75
|
+
# Ensure master hook is up-to-date
|
|
76
|
+
installer = Overcommit::Installer.new(logger)
|
|
77
|
+
if installer.run(Overcommit::Utils.repo_root, action: :update)
|
|
78
|
+
exec($0, *ARGV) # Execute the updated hook with all original arguments
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
|
|
82
|
+
|
|
83
|
+
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
|
84
|
+
config.apply_environment!(context, ENV)
|
|
85
|
+
|
|
86
|
+
printer = Overcommit::Printer.new(config, logger, context)
|
|
87
|
+
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
|
88
|
+
|
|
89
|
+
status = runner.run
|
|
90
|
+
|
|
91
|
+
exit(status ? 0 : 65) # 65 = EX_DATAERR
|
|
92
|
+
rescue Overcommit::Exceptions::ConfigurationError => e
|
|
93
|
+
puts e
|
|
94
|
+
exit 78 # EX_CONFIG
|
|
95
|
+
rescue Overcommit::Exceptions::HookContextLoadError => e
|
|
96
|
+
puts e
|
|
97
|
+
puts 'Are you running an old version of Overcommit?'
|
|
98
|
+
exit 69 # EX_UNAVAILABLE
|
|
99
|
+
rescue Overcommit::Exceptions::HookLoadError,
|
|
100
|
+
Overcommit::Exceptions::InvalidHookDefinition => e
|
|
101
|
+
puts e.message
|
|
102
|
+
puts e.backtrace
|
|
103
|
+
exit 78 # EX_CONFIG
|
|
104
|
+
rescue Overcommit::Exceptions::HookSetupFailed,
|
|
105
|
+
Overcommit::Exceptions::HookCleanupFailed => e
|
|
106
|
+
puts e.message
|
|
107
|
+
exit 74 # EX_IOERR
|
|
108
|
+
rescue Overcommit::Exceptions::HookCancelled
|
|
109
|
+
puts 'You cancelled the hook run'
|
|
110
|
+
exit 130 # Ctrl-C cancel
|
|
111
|
+
rescue Overcommit::Exceptions::InvalidGitRepo => e
|
|
112
|
+
puts e
|
|
113
|
+
exit 64 # EX_USAGE
|
|
114
|
+
rescue Overcommit::Exceptions::ConfigurationSignatureChanged => e
|
|
115
|
+
puts e
|
|
116
|
+
puts "For more information, see #{Overcommit::REPO_URL}#security"
|
|
117
|
+
exit 1
|
|
118
|
+
rescue Overcommit::Exceptions::InvalidHookSignature
|
|
119
|
+
exit 1
|
|
120
|
+
rescue StandardError => e
|
|
121
|
+
puts e.message
|
|
122
|
+
puts e.backtrace
|
|
123
|
+
puts "Report this bug at #{Overcommit::BUG_REPORT_URL}"
|
|
124
|
+
exit 70 # EX_SOFTWARE
|
|
125
|
+
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# Entrypoint for Overcommit hook integration. Installing Overcommit will result
|
|
5
|
+
# in all of your git hooks being copied from this file, allowing the framework
|
|
6
|
+
# to manage your hooks for you.
|
|
7
|
+
|
|
8
|
+
# Prevent a Ruby stack trace from appearing when we interrupt the hook.
|
|
9
|
+
# Note that this will be overridden when Overcommit is loaded, since the
|
|
10
|
+
# InterruptHandler will redefine the trap at that time.
|
|
11
|
+
Signal.trap('INT') do
|
|
12
|
+
puts 'Hook run interrupted'
|
|
13
|
+
exit 130
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Allow hooks to be disabled via environment variable so git commands can be run
|
|
17
|
+
# in scripts without Overcommit running hooks
|
|
18
|
+
if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
|
|
19
|
+
exit
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
hook_type = File.basename($0)
|
|
23
|
+
if hook_type == 'overcommit-hook'
|
|
24
|
+
puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \
|
|
25
|
+
"by each hook in a repository's .git/hooks directory."
|
|
26
|
+
exit 64 # EX_USAGE
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Check if Overcommit should invoke a Bundler context for loading gems
|
|
30
|
+
require 'yaml'
|
|
31
|
+
# rubocop:disable Style/RescueModifier
|
|
32
|
+
gemfile =
|
|
33
|
+
begin
|
|
34
|
+
YAML.load_file('.overcommit.yml', aliases: true)['gemfile']
|
|
35
|
+
rescue ArgumentError
|
|
36
|
+
YAML.load_file('.overcommit.yml')['gemfile']
|
|
37
|
+
end rescue nil
|
|
38
|
+
|
|
39
|
+
if gemfile
|
|
40
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
|
41
|
+
require 'bundler'
|
|
42
|
+
|
|
43
|
+
begin
|
|
44
|
+
Bundler.setup
|
|
45
|
+
rescue Bundler::BundlerError => e
|
|
46
|
+
puts "Problem loading '#{gemfile}': #{e.message}"
|
|
47
|
+
puts "Try running:\nbundle install --gemfile=#{gemfile}" if e.is_a?(Bundler::GemNotFound)
|
|
48
|
+
exit 78 # EX_CONFIG
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
# rubocop:enable Style/RescueModifier
|
|
52
|
+
|
|
53
|
+
begin
|
|
54
|
+
require 'overcommit'
|
|
55
|
+
puts 'Signing Overcommit hooks...'
|
|
56
|
+
exec('overcommit --sign')
|
|
57
|
+
rescue LoadError
|
|
58
|
+
if gemfile
|
|
59
|
+
puts 'You have specified the `gemfile` option in your Overcommit ' \
|
|
60
|
+
'configuration but have not added the `overcommit` gem to ' \
|
|
61
|
+
"#{gemfile}."
|
|
62
|
+
else
|
|
63
|
+
puts 'This repository contains hooks installed by Overcommit, but the ' \
|
|
64
|
+
"`overcommit` gem is not installed.\n" \
|
|
65
|
+
'Install it with `gem install overcommit`.'
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
exit 64 # EX_USAGE
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
begin
|
|
72
|
+
logger = Overcommit::Logger.new(STDOUT)
|
|
73
|
+
Overcommit::Utils.log = logger
|
|
74
|
+
|
|
75
|
+
# Ensure master hook is up-to-date
|
|
76
|
+
installer = Overcommit::Installer.new(logger)
|
|
77
|
+
if installer.run(Overcommit::Utils.repo_root, action: :update)
|
|
78
|
+
exec($0, *ARGV) # Execute the updated hook with all original arguments
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
|
|
82
|
+
|
|
83
|
+
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
|
84
|
+
config.apply_environment!(context, ENV)
|
|
85
|
+
|
|
86
|
+
printer = Overcommit::Printer.new(config, logger, context)
|
|
87
|
+
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
|
88
|
+
|
|
89
|
+
status = runner.run
|
|
90
|
+
|
|
91
|
+
exit(status ? 0 : 65) # 65 = EX_DATAERR
|
|
92
|
+
rescue Overcommit::Exceptions::ConfigurationError => e
|
|
93
|
+
puts e
|
|
94
|
+
exit 78 # EX_CONFIG
|
|
95
|
+
rescue Overcommit::Exceptions::HookContextLoadError => e
|
|
96
|
+
puts e
|
|
97
|
+
puts 'Are you running an old version of Overcommit?'
|
|
98
|
+
exit 69 # EX_UNAVAILABLE
|
|
99
|
+
rescue Overcommit::Exceptions::HookLoadError,
|
|
100
|
+
Overcommit::Exceptions::InvalidHookDefinition => e
|
|
101
|
+
puts e.message
|
|
102
|
+
puts e.backtrace
|
|
103
|
+
exit 78 # EX_CONFIG
|
|
104
|
+
rescue Overcommit::Exceptions::HookSetupFailed,
|
|
105
|
+
Overcommit::Exceptions::HookCleanupFailed => e
|
|
106
|
+
puts e.message
|
|
107
|
+
exit 74 # EX_IOERR
|
|
108
|
+
rescue Overcommit::Exceptions::HookCancelled
|
|
109
|
+
puts 'You cancelled the hook run'
|
|
110
|
+
exit 130 # Ctrl-C cancel
|
|
111
|
+
rescue Overcommit::Exceptions::InvalidGitRepo => e
|
|
112
|
+
puts e
|
|
113
|
+
exit 64 # EX_USAGE
|
|
114
|
+
rescue Overcommit::Exceptions::ConfigurationSignatureChanged => e
|
|
115
|
+
puts e
|
|
116
|
+
puts "For more information, see #{Overcommit::REPO_URL}#security"
|
|
117
|
+
exit 1
|
|
118
|
+
rescue Overcommit::Exceptions::InvalidHookSignature
|
|
119
|
+
exit 1
|
|
120
|
+
rescue StandardError => e
|
|
121
|
+
puts e.message
|
|
122
|
+
puts e.backtrace
|
|
123
|
+
puts "Report this bug at #{Overcommit::BUG_REPORT_URL}"
|
|
124
|
+
exit 70 # EX_SOFTWARE
|
|
125
|
+
end
|
|
@@ -4,14 +4,20 @@ require 'rails/generators/base'
|
|
|
4
4
|
|
|
5
5
|
module CodeQualityCheck
|
|
6
6
|
module Generators
|
|
7
|
-
#
|
|
7
|
+
# Rails generator that removes CodeQualityCheck configuration and uninstalls
|
|
8
|
+
# Overcommit hooks.
|
|
9
|
+
#
|
|
10
|
+
# Run with: +rails generate code_quality_check:uninstall+
|
|
11
|
+
#
|
|
12
|
+
# Removes: config/initializers/code_quality_check.rb, .overcommit.yml, .rubocop.yml
|
|
13
|
+
# Runs: bundle exec overcommit --uninstall
|
|
8
14
|
class UninstallGenerator < Rails::Generators::Base
|
|
9
15
|
desc 'This generator removes Overcommit and RuboCop configuration files'
|
|
10
16
|
|
|
11
17
|
# Remove Overcommit and RuboCop configuration files
|
|
12
18
|
def remove_files
|
|
13
19
|
# List of files to be removed
|
|
14
|
-
files_to_remove = ['config/initializers/
|
|
20
|
+
files_to_remove = ['config/initializers/code_quality_check.rb', '.overcommit.yml', '.rubocop.yml']
|
|
15
21
|
|
|
16
22
|
files_to_remove.each do |file|
|
|
17
23
|
if File.exist?(file)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: code_quality_check
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aniruddha Mirajkar
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-03-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: brakeman
|
|
@@ -24,6 +24,20 @@ dependencies:
|
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: 5.4.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bundler-audit
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0.9'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0.9'
|
|
27
41
|
- !ruby/object:Gem::Dependency
|
|
28
42
|
name: rails_best_practices
|
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -72,8 +86,35 @@ dependencies:
|
|
|
72
86
|
- - ">="
|
|
73
87
|
- !ruby/object:Gem::Version
|
|
74
88
|
version: 1.23.1
|
|
75
|
-
|
|
76
|
-
|
|
89
|
+
- !ruby/object:Gem::Dependency
|
|
90
|
+
name: rails
|
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '6.0'
|
|
96
|
+
- - "<"
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: '9'
|
|
99
|
+
type: :development
|
|
100
|
+
prerelease: false
|
|
101
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
102
|
+
requirements:
|
|
103
|
+
- - ">="
|
|
104
|
+
- !ruby/object:Gem::Version
|
|
105
|
+
version: '6.0'
|
|
106
|
+
- - "<"
|
|
107
|
+
- !ruby/object:Gem::Version
|
|
108
|
+
version: '9'
|
|
109
|
+
description: |
|
|
110
|
+
Code Quality Check is a Ruby on Rails gem that runs automated quality and security
|
|
111
|
+
checks on every commit using Overcommit and Git hooks. It bundles and configures
|
|
112
|
+
RuboCop (style and lint), Brakeman (security), Rails Best Practices, and
|
|
113
|
+
BundleAudit (CVE checks). The installer sets up a Rails initializer that verifies
|
|
114
|
+
the gem is installed and ensures Overcommit hooks are present, so teams don't
|
|
115
|
+
silently skip checks. Optional support for Reek, Flay, and Fasterer via
|
|
116
|
+
.overcommit.yml. Requires Overcommit in your Gemfile; add the gem and run
|
|
117
|
+
`rails generate code_quality_check:install` to get started.
|
|
77
118
|
email:
|
|
78
119
|
- mirajkaraniruddha@gmail.com
|
|
79
120
|
executables: []
|
|
@@ -83,8 +124,10 @@ files:
|
|
|
83
124
|
- lib/code_quality_check.rb
|
|
84
125
|
- lib/code_quality_check/version.rb
|
|
85
126
|
- lib/generators/code_quality_check/install_generator.rb
|
|
86
|
-
- lib/generators/code_quality_check/templates/
|
|
127
|
+
- lib/generators/code_quality_check/templates/code_quality_check.rb
|
|
87
128
|
- lib/generators/code_quality_check/templates/overcommit.yml
|
|
129
|
+
- lib/generators/code_quality_check/templates/post-checkout
|
|
130
|
+
- lib/generators/code_quality_check/templates/pre-commit
|
|
88
131
|
- lib/generators/code_quality_check/templates/rubocop.yml
|
|
89
132
|
- lib/generators/code_quality_check/uninstall_generator.rb
|
|
90
133
|
homepage: https://github.com/aniruddhami/code_quality_check
|
|
@@ -94,6 +137,7 @@ metadata:
|
|
|
94
137
|
homepage_uri: https://github.com/aniruddhami/code_quality_check
|
|
95
138
|
source_code_uri: https://github.com/aniruddhami/code_quality_check
|
|
96
139
|
changelog_uri: https://github.com/aniruddhami/code_quality_check/blob/main/CHANGELOG.md
|
|
140
|
+
documentation_uri: https://github.com/aniruddhami/code_quality_check#readme
|
|
97
141
|
github_repo: https://github.com/aniruddhami/code_quality_check
|
|
98
142
|
rubygems_mfa_required: 'true'
|
|
99
143
|
post_install_message:
|
|
@@ -111,8 +155,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
111
155
|
- !ruby/object:Gem::Version
|
|
112
156
|
version: '0'
|
|
113
157
|
requirements: []
|
|
114
|
-
rubygems_version: 3.
|
|
158
|
+
rubygems_version: 3.4.19
|
|
115
159
|
signing_key:
|
|
116
160
|
specification_version: 4
|
|
117
|
-
summary:
|
|
161
|
+
summary: Enforce code quality on every commit via Overcommit and Git hooks
|
|
118
162
|
test_files: []
|