dvla-lint 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/gem-push.yml +48 -0
- data/.github/workflows/gem-test.yml +22 -0
- data/.gitignore +19 -0
- data/.rspec +3 -0
- data/.rubocop.yml +26 -0
- data/.ruby-version +1 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +32 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/dvla-lint.gemspec +41 -0
- data/exe/dvla-lint +66 -0
- data/lib/dvla/lint/version.rb +7 -0
- data/lib/dvla/lint.rb +13 -0
- data/rules/dvla-ruby-styleguide.yml +663 -0
- data/rules/other-excludes.yml +19 -0
- data/rules/other-gemspec.yml +7 -0
- data/rules/other-lint.yml +161 -0
- data/rules/other-metrics.yml +11 -0
- data/rules/other-rails.yml +42 -0
- data/rules/other-security.yml +3 -0
- data/rules/other-style.yml +522 -0
- metadata +197 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 72c31e71d99c27af1ab416f1fa695286693b16f5459ad824ad2d5e5d7065d34e
|
4
|
+
data.tar.gz: ea7aa626fc01401f918ae488dfadf21996ec7ea1e70987f7723f32d91eafe5eb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 94c1f886033f02968f2c2841ac8c8336e70a8ac2aaf93f6365a7f79041ce86eabb5526edbbc2aace81ffbf5315440ad6a10d27af9b55746a386a26cd70a1a837
|
7
|
+
data.tar.gz: 0f74671106a74c8cd8a46c4f9a630cb3a4a7a7c0dd68471252e97e15dc4616642ab7d946e2927d603174d9a1c841211862472491a8cda0a9018733d4b4df277b
|
@@ -0,0 +1,48 @@
|
|
1
|
+
name: Ruby Gem Publish
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ "main" ]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
ruby-version: [ '3.0', '3.1', '3.2' ]
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- name: Set up Ruby
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby-version }}
|
20
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
21
|
+
- name: Run tests
|
22
|
+
run: bundle exec rspec
|
23
|
+
|
24
|
+
deploy:
|
25
|
+
needs: test
|
26
|
+
runs-on: ubuntu-latest
|
27
|
+
permissions:
|
28
|
+
packages: write
|
29
|
+
contents: read
|
30
|
+
|
31
|
+
steps:
|
32
|
+
- uses: actions/checkout@v2
|
33
|
+
- name: Set up Ruby 3.2.2
|
34
|
+
uses: ruby/setup-ruby@v1
|
35
|
+
with:
|
36
|
+
ruby-version: 3.2.2
|
37
|
+
bundler-cache: true
|
38
|
+
|
39
|
+
- name: Publish to RubyGems
|
40
|
+
run: |
|
41
|
+
mkdir -p $HOME/.gem
|
42
|
+
touch $HOME/.gem/credentials
|
43
|
+
chmod 0600 $HOME/.gem/credentials
|
44
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
45
|
+
gem build *.gemspec
|
46
|
+
gem push *.gem
|
47
|
+
env:
|
48
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: Ruby Test
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches: [ "main" ]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
ruby-version: [ '3.0', '3.1', '3.2' ]
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- name: Set up Ruby
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby-version }}
|
20
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
21
|
+
- name: Run tests
|
22
|
+
run: bundle exec rspec
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
AllCops:
|
2
|
+
DisplayCopNames:
|
3
|
+
Description: 'Display cop names in offense messages'
|
4
|
+
Enabled: true
|
5
|
+
|
6
|
+
ExtraDetails:
|
7
|
+
Description: 'Display extra details in offense messages.'
|
8
|
+
Enabled: true
|
9
|
+
|
10
|
+
DisplayStyleGuide:
|
11
|
+
Description: 'Display style guide URLs in offense messages.'
|
12
|
+
Enabled: true
|
13
|
+
|
14
|
+
require:
|
15
|
+
- rubocop-rails
|
16
|
+
- rubocop-performance
|
17
|
+
|
18
|
+
inherit_from:
|
19
|
+
- rules/dvla-ruby-styleguide.yml
|
20
|
+
- rules/other-lint.yml
|
21
|
+
- rules/other-rails.yml
|
22
|
+
- rules/other-style.yml
|
23
|
+
- rules/other-metrics.yml
|
24
|
+
- rules/other-excludes.yml
|
25
|
+
- rules/other-gemspec.yml
|
26
|
+
- rules/other-security.yml
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.2
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 HM Government (Driver and Vehicle Licensing Agency)
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# DVLA::Lint
|
2
|
+
|
3
|
+
This Gem contains the official DVLA Ruby linting rules for all of the Agency's Ruby-based work. It's a fork of the GDS rules contained in GOVUK-Lint (as of commit [0d2d442
|
4
|
+
](https://github.com/alphagov/govuk-lint/commit/0d2d4423703f4975e63768a75095e3b989f02d21)) repackaged without with Sass or CLI components and updated to DVLA's house style.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'dvla-lint", "~> <major_version>.<minor_version>'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
```shell
|
17
|
+
bundle
|
18
|
+
```
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
```shell
|
23
|
+
gem install dvla-lint
|
24
|
+
```
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
With the gem added to your Gemfile and installed, execute this to install the default DVLA Rubocop configuration in your current directory:
|
29
|
+
|
30
|
+
```shell
|
31
|
+
bundle exec dvla-lint init
|
32
|
+
```
|
data/Rakefile
ADDED
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 'dvla/lint'
|
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
data/dvla-lint.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'dvla/lint/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'dvla-lint'
|
9
|
+
spec.version = Dvla::Lint::VERSION
|
10
|
+
spec.authors = ['Driver and Vehicle Licensing Agency (DVLA)', 'Nigel Brookes-Thomas']
|
11
|
+
spec.email = ['nigel.brookes-thomas@dvla.gov.uk']
|
12
|
+
|
13
|
+
spec.summary = 'Rubocop standard rules'
|
14
|
+
spec.description = 'The standard Rubocop rules for the DVLA'
|
15
|
+
spec.homepage = 'https://github.com/dvla/dvla-lint-ruby'
|
16
|
+
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
|
+
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = %w[lib]
|
30
|
+
|
31
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
32
|
+
spec.add_development_dependency 'pry', '~> 0.12'
|
33
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
34
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
35
|
+
|
36
|
+
spec.add_runtime_dependency 'rubocop', '~> 1.44'
|
37
|
+
spec.add_runtime_dependency 'rubocop-performance', '~> 1.5'
|
38
|
+
spec.add_runtime_dependency 'rubocop-rails', '~> 2.17'
|
39
|
+
spec.add_runtime_dependency 'tty-config', '~> 0.5'
|
40
|
+
spec.add_runtime_dependency 'tty-prompt', '~> 0.23'
|
41
|
+
end
|
data/exe/dvla-lint
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'tty-config'
|
5
|
+
require 'tty-prompt'
|
6
|
+
|
7
|
+
def prompt
|
8
|
+
@prompt ||= TTY::Prompt.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def config
|
12
|
+
unless @config
|
13
|
+
@config ||= TTY::Config.new do |c|
|
14
|
+
c.filename = '.rubocop'
|
15
|
+
c.set(:inherit_gem, :'dvla-lint', value: '.rubocop.yml')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
@config
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_file
|
22
|
+
prompt_text = 'Which type of project are you building?'
|
23
|
+
choices = [
|
24
|
+
'Plain old Ruby files',
|
25
|
+
'Functional tests with Cucumber',
|
26
|
+
'Ruby on Rails project',
|
27
|
+
]
|
28
|
+
choice = prompt.select(prompt_text, choices)
|
29
|
+
config.set(:Rails, :Enabled, value: true) if choice == choices[2] # Rails
|
30
|
+
config.write(force: true)
|
31
|
+
puts 'Done'
|
32
|
+
end
|
33
|
+
|
34
|
+
def config_file_exists
|
35
|
+
prompt_text = 'WARNING: you already have a rubocop configuration, ' \
|
36
|
+
"do you want to overwrite it with the DVLA rubocop configuration?\n" \
|
37
|
+
"(#{file_name})"
|
38
|
+
create_file if prompt.yes?(prompt_text)
|
39
|
+
end
|
40
|
+
|
41
|
+
def config_file_new
|
42
|
+
prompt_text = "Do you want to install the default DVLA rubocop configuration?\n" \
|
43
|
+
"(#{file_name})"
|
44
|
+
create_file if prompt.yes?(prompt_text)
|
45
|
+
end
|
46
|
+
|
47
|
+
def file_name
|
48
|
+
File.join(Dir.pwd, '.rubocop.yml')
|
49
|
+
end
|
50
|
+
|
51
|
+
def create_config
|
52
|
+
if File.exist?(file_name)
|
53
|
+
config_file_exists
|
54
|
+
else
|
55
|
+
config_file_new
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
if ARGV[0]&.strip.eql? 'init'
|
60
|
+
create_config
|
61
|
+
else
|
62
|
+
puts <<~USAGE
|
63
|
+
Usage:
|
64
|
+
dvla-lint init # create or overwrite a default Rubocop configuration
|
65
|
+
USAGE
|
66
|
+
end
|
data/lib/dvla/lint.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dvla/lint/version'
|
4
|
+
|
5
|
+
module Dvla # :nodoc:
|
6
|
+
# This is the wrapper module for the DVLA-Linting rules.
|
7
|
+
# There is nothing in here other than the version number,
|
8
|
+
# with the rules themselves in the /rules directory and loaded
|
9
|
+
# by the .rubocop.yml at this gem's root.
|
10
|
+
module Lint
|
11
|
+
# There's nothing to see here
|
12
|
+
end
|
13
|
+
end
|