code_quality_check 0.1.6 → 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 +12 -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/uninstall_generator.rb +8 -2
- metadata +48 -6
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,7 +4,17 @@ 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'
|
|
@@ -17,7 +27,7 @@ module CodeQualityCheck
|
|
|
17
27
|
# Define a method that copies the initializer file to the config/initializers directory
|
|
18
28
|
def copy_required_files
|
|
19
29
|
# Copy the initializer file to the config/initializers directory
|
|
20
|
-
template '
|
|
30
|
+
template 'code_quality_check.rb', 'config/initializers/code_quality_check.rb'
|
|
21
31
|
|
|
22
32
|
# Copy the Overcommit configuration file to the root directory
|
|
23
33
|
template 'overcommit.yml', '.overcommit.yml'
|
|
@@ -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
|
|
|
@@ -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,7 +124,7 @@ 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
|
|
88
129
|
- lib/generators/code_quality_check/templates/post-checkout
|
|
89
130
|
- lib/generators/code_quality_check/templates/pre-commit
|
|
@@ -96,6 +137,7 @@ metadata:
|
|
|
96
137
|
homepage_uri: https://github.com/aniruddhami/code_quality_check
|
|
97
138
|
source_code_uri: https://github.com/aniruddhami/code_quality_check
|
|
98
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
|
|
99
141
|
github_repo: https://github.com/aniruddhami/code_quality_check
|
|
100
142
|
rubygems_mfa_required: 'true'
|
|
101
143
|
post_install_message:
|
|
@@ -116,5 +158,5 @@ requirements: []
|
|
|
116
158
|
rubygems_version: 3.4.19
|
|
117
159
|
signing_key:
|
|
118
160
|
specification_version: 4
|
|
119
|
-
summary:
|
|
161
|
+
summary: Enforce code quality on every commit via Overcommit and Git hooks
|
|
120
162
|
test_files: []
|