Skip to content

Commit 9150a98

Browse files
authored
Merge pull request rails#48216 from zzak/import-rails-bin-linter
Import rails-bin linter to rails internal tools lib
2 parents 11aa3fd + 32b8e66 commit 9150a98

34 files changed

+2720
-13
lines changed

.github/workflows/lint.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,16 @@ jobs:
2727
uses: actions/setup-python@v3
2828
with:
2929
python-version: "3.10"
30+
3031
- name: Install dependencies
3132
run: |
3233
python -m pip install --upgrade pip
3334
pip install codespell==2.1.0
3435
- name: Check spelling with codespell
3536
run: codespell --ignore-words=codespell.txt --skip="./vendor/bundle,./actionview/test/ujs/public/vendor/qunit.js,./actiontext/app/assets/javascripts/trix.js,./yarn.lock" || exit 1
3637

37-
- uses: actions/checkout@v4
38-
with:
39-
repository: skipkayhil/rails-bin
40-
ref: 748f4673a5fe5686b5859e89f814166280e51781
41-
- uses: ruby/setup-ruby@v1
42-
with:
43-
ruby-version: 3.2
44-
bundler-cache: true
45-
- uses: actions/checkout@v4
46-
with:
47-
path: rails
48-
- run: bin/check-changelogs ./rails
49-
- run: bin/check-config-docs ./rails
38+
- run: tools/railspect changelogs .
39+
- run: tools/railspect configuration .
5040

5141
- uses: zzak/action-discord@v8
5242
continue-on-error: true

.github/workflows/rail_inspector.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Rail Inspector
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "tools/rail_inspector/**"
7+
push:
8+
paths:
9+
- "tools/rail_inspector/**"
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
rail_inspector:
16+
name: rail_inspector tests
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- uses: ruby/setup-ruby@v1
21+
with:
22+
ruby-version: 3.2
23+
bundler-cache: true
24+
- run: cd tools/rail_inspector && bundle exec rake

.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ AllCops:
1919
- 'actionmailbox/test/dummy/**/*'
2020
- 'activestorage/test/dummy/**/*'
2121
- 'actiontext/test/dummy/**/*'
22+
- 'tools/rail_inspector/test/fixtures/*'
2223
- '**/node_modules/**/*'
2324
- '**/CHANGELOG.md'
2425
- '**/2_*_release_notes.md'

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ gem "json", ">= 2.0.0"
4545
# Workaround until Ruby ships with cgi version 0.3.6 or higher.
4646
gem "cgi", ">= 0.3.6", require: false
4747

48+
group :lint do
49+
gem "syntax_tree", "6.1.1", require: false
50+
end
51+
4852
group :rubocop do
4953
gem "rubocop", ">= 1.25.1", require: false
5054
gem "rubocop-minitest", require: false

Gemfile.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ GEM
369369
ast (~> 2.4.1)
370370
path_expander (1.1.1)
371371
pg (1.5.3)
372+
prettier_print (1.2.1)
372373
propshaft (0.6.4)
373374
actionpack (>= 7.0.0)
374375
activesupport (>= 7.0.0)
@@ -513,6 +514,8 @@ GEM
513514
stringio (3.0.7)
514515
sucker_punch (3.1.0)
515516
concurrent-ruby (~> 1.0)
517+
syntax_tree (6.1.1)
518+
prettier_print (>= 1.2.0)
516519
tailwindcss-rails (2.0.21)
517520
railties (>= 6.0.0)
518521
tailwindcss-rails (2.0.21-x86_64-darwin)
@@ -631,6 +634,7 @@ DEPENDENCIES
631634
stackprof
632635
stimulus-rails
633636
sucker_punch
637+
syntax_tree (= 6.1.1)
634638
tailwindcss-rails
635639
terser (>= 1.1.4)
636640
trilogy (>= 2.5.0)

tools/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ They aren't used by Rails apps directly.
55

66
* `console` drops you in irb and loads local Rails repos
77
* `profile` profiles `Kernel#require` to help reduce startup time
8+
* `railspect` provides commands to run internal linters
89
* `line_statistics` provides CodeTools module and LineStatistics class to count lines
910
* `test` is loaded by every major component of Rails to simplify testing, for example:
1011
`cd ./actioncable; bin/test ./path/to/actioncable_test_with_line_number.rb:5`

tools/rail_inspector/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Hartley McGuire
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.

tools/rail_inspector/Rakefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
require "bundler/gem_tasks"
4+
require "minitest/test_task"
5+
require "rubocop/rake_task"
6+
7+
Minitest::TestTask.create
8+
9+
RuboCop::RakeTask.new
10+
11+
task default: [:test, :rubocop]

tools/rail_inspector/bin/console

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require "bundler/setup"
5+
require_relative "../lib/rail_inspector"
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__)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "rail_inspector/version"
4+
5+
# MIT License
6+
#
7+
# Copyright (c) Hartley McGuire
8+
#
9+
# Permission is hereby granted, free of charge, to any person obtaining a copy
10+
# of this software and associated documentation files (the "Software"), to deal
11+
# in the Software without restriction, including without limitation the rights
12+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
# copies of the Software, and to permit persons to whom the Software is
14+
# furnished to do so, subject to the following conditions:
15+
#
16+
# The above copyright notice and this permission notice shall be included in all
17+
# copies or substantial portions of the Software.
18+
#
19+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
# SOFTWARE.
26+
27+
module RailInspector
28+
end

0 commit comments

Comments
 (0)