Skip to content

Commit 25ceb5f

Browse files
authored
Switch from Prettier to Rubocop (#269)
This project currently has three language dependencies for development: * Ruby, for the library code and testing * Javascript, for linting with Prettier and installing commit hooks with Husky * Python, for creating the docsite In an effort to reduce these dependencies, I'm moving to eliminate JS from the dev environment, starting with Prettier. I may replace Husky with Overcommit or a bespoke script.
1 parent 9e13afc commit 25ceb5f

File tree

309 files changed

+8071
-7435
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

309 files changed

+8071
-7435
lines changed

.github/workflows/super_diff.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
uses: ruby/setup-ruby@v1
3131
with:
3232
bundler-cache: true
33+
- name: Install Ruby dependencies
34+
run: bundle install
3335
- name: Use Node.js
3436
uses: actions/setup-node@v4
3537
with:
@@ -38,8 +40,10 @@ jobs:
3840
- name: Install Yarn dependencies
3941
run: yarn --immutable
4042
- name: Lint
41-
run: yarn lint
42-
- name: Audit
43+
run: bundle exec rubocop --parallel
44+
- name: Audit Ruby
45+
run: bundle exec bundle-audit check --update
46+
- name: Audit JS
4347
run: yarn audit
4448

4549
test:
@@ -70,17 +74,6 @@ jobs:
7074
with:
7175
ruby-version: ${{ matrix.ruby }}
7276
bundler-cache: true
73-
- name: Install Zeus
74-
run: gem install zeus
75-
- name: Start Zeus
76-
uses: JarvusInnovations/background-action@v1
77-
with:
78-
run: zeus start
79-
wait-on: |
80-
socket:.zeus.sock
81-
file:.zeus.sock
82-
wait-for: 15s
83-
log-output-if: failure
8477
- name: Run tests
8578
run: bundle exec rake --trace
8679

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.DS_Store
2-
Gemfile.lock
32
gemfiles/.bundle
43
gemfiles/*.gemfile.lock
54
node_modules

.husky/pre-push

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ if echo "$stdin" | grep -q "^(delete)"; then
99
exit 0
1010
fi
1111

12-
scripts/lint-changed-files.sh --check
12+
scripts/lint-changed-files.sh
1313

1414
echo
1515
echo "*** Auditing dependencies ***************"
1616
echo
1717

1818
yarn audit || exit $?
19+
bundle exec bundle-audit || exit $?
1920

2021
echo

.prettierignore

Lines changed: 0 additions & 8 deletions
This file was deleted.

.prettierrc.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

.rubocop.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
inherit_from: .rubocop_todo.yml
2+
inherit_mode:
3+
merge:
4+
- Exclude
5+
6+
# The behavior of RuboCop can be controlled via the .rubocop.yml
7+
# configuration file. It makes it possible to enable/disable
8+
# certain cops (checks) and to alter their behavior if they accept
9+
# any parameters. The file can be placed either in your home
10+
# directory or in some project directory.
11+
#
12+
# RuboCop will start looking for the configuration file in the directory
13+
# where the inspected file is and continue its way up to the root directory.
14+
#
15+
# See https://docs.rubocop.org/rubocop/configuration
16+
AllCops:
17+
NewCops: enable
18+
SuggestExtensions:
19+
rubocop-rake: false
20+
Exclude:
21+
- 'gemfiles/**' # these are auto-generated by Appraisal
22+
- 'tmp/**'
23+
- 'vendor/**'
24+
- vendor/**/*.rb
25+
- gemfiles/vendor/bundle/**/*
26+
27+
Layout/LineLength:
28+
Exclude:
29+
- 'spec/**/*'
30+
31+
Lint/SuppressedException:
32+
Exclude:
33+
- 'spec/spec_helper.rb'
34+
- 'support/test_plan.rb'
35+
36+
Naming/FileName:
37+
Exclude:
38+
- 'lib/super_diff/rspec-rails.rb'
39+
40+
Naming/VariableNumber:
41+
Enabled: false

.rubocop_todo.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config --auto-gen-only-exclude`
3+
# on 2024-10-19 10:08:34 UTC using RuboCop version 1.67.0.
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: 31
10+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
11+
Metrics/AbcSize:
12+
Max: 112
13+
Exclude:
14+
- 'lib/super_diff/basic/operation_tree_builders/hash.rb'
15+
16+
# Offense count: 993
17+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
18+
# AllowedMethods: refine
19+
Metrics/BlockLength:
20+
Max: 5536
21+
22+
# Offense count: 2
23+
# Configuration parameters: CountBlocks, CountModifierForms, Max.
24+
Metrics/BlockNesting:
25+
Exclude:
26+
- 'lib/super_diff/basic/operation_tree_builders/hash.rb'
27+
28+
# Offense count: 13
29+
# Configuration parameters: CountComments, Max, CountAsOne.
30+
Metrics/ClassLength:
31+
Exclude:
32+
- 'lib/super_diff/basic/diff_formatters/collection.rb'
33+
- 'lib/super_diff/basic/operation_tree_builders/hash.rb'
34+
- 'lib/super_diff/basic/operation_tree_flatteners/collection.rb'
35+
- 'lib/super_diff/core/configuration.rb'
36+
- 'lib/super_diff/core/inspection_tree.rb'
37+
- 'lib/super_diff/core/tiered_lines_elider.rb'
38+
- 'lib/super_diff/csi/document.rb'
39+
- 'lib/super_diff/csi/eight_bit_color.rb'
40+
- 'lib/super_diff/csi/four_bit_color.rb'
41+
- 'lib/super_diff/rspec/matcher_text_builders/base.rb'
42+
- 'spec/support/command_runner.rb'
43+
- 'spec/support/integration/test_programs/base.rb'
44+
- 'support/test_plan.rb'
45+
46+
# Offense count: 3
47+
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
48+
Metrics/CyclomaticComplexity:
49+
Exclude:
50+
- 'lib/super_diff/basic/operation_tree_builders/hash.rb'
51+
- 'lib/super_diff/core/abstract_operation_tree_builder.rb'
52+
- 'lib/super_diff/csi/document.rb'
53+
54+
# Offense count: 89
55+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
56+
Metrics/MethodLength:
57+
Max: 114
58+
59+
# Offense count: 1
60+
# Configuration parameters: CountComments, Max, CountAsOne.
61+
Metrics/ModuleLength:
62+
Exclude:
63+
- 'lib/super_diff.rb'
64+
65+
# Offense count: 3
66+
# Configuration parameters: Max, CountKeywordArgs, MaxOptionalParameters.
67+
Metrics/ParameterLists:
68+
Exclude:
69+
- 'lib/super_diff/csi/eight_bit_color.rb'
70+
- 'spec/support/integration/helpers.rb'
71+
- 'spec/support/models/player.rb'
72+
73+
# Offense count: 4
74+
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
75+
Metrics/PerceivedComplexity:
76+
Exclude:
77+
- 'lib/super_diff/basic/operation_tree_builders/hash.rb'
78+
- 'lib/super_diff/core/abstract_operation_tree_builder.rb'
79+
- 'lib/super_diff/core/tiered_lines_elider.rb'
80+
- 'lib/super_diff/csi/document.rb'
81+
82+
# Offense count: 1
83+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
84+
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
85+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
86+
87+
# Offense count: 207
88+
# Configuration parameters: AllowedConstants.
89+
Style/Documentation:
90+
Enabled: false
91+
92+
# Offense count: 3
93+
# This cop supports safe autocorrection (--autocorrect).
94+
# Configuration parameters: EnforcedStyle.
95+
# SupportedStyles: format, sprintf, percent
96+
Style/FormatString:
97+
Exclude:
98+
- 'lib/super_diff/core/helpers.rb'
99+
- 'spec/unit/core/helpers_spec.rb'
100+
101+
# Offense count: 2
102+
# This cop supports unsafe autocorrection (--autocorrect-all).
103+
# Configuration parameters: EnforcedStyle, Autocorrect.
104+
# SupportedStyles: module_function, extend_self, forbidden
105+
Style/ModuleFunction:
106+
Exclude:
107+
- 'lib/super_diff/core/helpers.rb'
108+
- 'spec/support/unit/helpers.rb'

Appraisals

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1+
# frozen_string_literal: true
2+
13
rails_dependencies =
24
proc do
3-
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
4-
gem "jdbc-sqlite3", platform: :jruby
5-
gem "net-ftp"
6-
gem "combustion"
5+
gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
6+
gem 'jdbc-sqlite3', platform: :jruby
7+
gem 'net-ftp'
8+
gem 'combustion'
79
end
810

911
appraisals = {
1012
rails_6_0:
1113
proc do
1214
instance_eval(&rails_dependencies)
1315

14-
gem "rails", "~> 6.0.0"
15-
gem "sqlite3", "~> 1.4.0", platform: %i[ruby mswin mingw]
16+
gem 'rails', '~> 6.0.0'
17+
gem 'sqlite3', '~> 1.4.0', platform: %i[ruby mswin mingw]
1618
end,
1719
rails_6_1:
1820
proc do
1921
instance_eval(&rails_dependencies)
2022

21-
gem "rails", "~> 6.1.0"
22-
gem "sqlite3", "~> 1.4.0", platform: %i[ruby mswin mingw]
23+
gem 'rails', '~> 6.1.0'
24+
gem 'sqlite3', '~> 1.4.0', platform: %i[ruby mswin mingw]
2325
end,
2426
rails_7_0:
2527
proc do
2628
instance_eval(&rails_dependencies)
2729

28-
gem "rails", "~> 7.0.0"
29-
gem "sqlite3", "~> 1.4.0", platform: %i[ruby mswin mingw]
30+
gem 'rails', '~> 7.0.0'
31+
gem 'sqlite3', '~> 1.4.0', platform: %i[ruby mswin mingw]
3032
end,
3133
no_rails: proc {},
3234
rspec_lt_3_10:
3335
proc do |with_rails|
34-
version = "~> 3.9.0"
36+
version = '~> 3.9.0'
3537

36-
gem "rspec", version
38+
gem 'rspec', version
3739

38-
gem "rspec-rails" if with_rails
40+
gem 'rspec-rails' if with_rails
3941
end,
4042
rspec_gte_3_10:
4143
proc do |with_rails|
42-
version = [">= 3.10", "< 4"]
43-
4444
# gem "rspec", *version
4545

46-
gem "rspec", "3.12.0"
47-
gem "rspec-core", "3.12.0"
48-
gem "rspec-expectations", "3.12.3"
49-
gem "rspec-mocks", "3.12.0"
50-
gem "rspec-support", "3.12.0"
46+
gem 'rspec', '3.12.0'
47+
gem 'rspec-core', '3.12.0'
48+
gem 'rspec-expectations', '3.12.3'
49+
gem 'rspec-mocks', '3.12.0'
50+
gem 'rspec-support', '3.12.0'
5151

52-
gem "rspec-rails" if with_rails
52+
gem 'rspec-rails' if with_rails
5353
end
5454
}
5555

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
- Fix multiline string diff with blank lines. [#266](https://github.com/splitwise/super_diff/pull/263)
99
- Improve inspection of Range objects. [#267](https://github.com/splitwise/super_diff/pull/267)
1010

11+
### Other changes
12+
13+
- Switch from Prettier to Rubocop. [#269](https://github.com/splitwise/super_diff/pull/269)
14+
1115
## 0.13.0 - 2024-09-22
1216

1317
### Features

Gemfile

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# frozen_string_literal: true
22

3-
source "https://rubygems.org"
3+
source 'https://rubygems.org'
44

55
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
66

7-
gem "appraisal", github: "thoughtbot/appraisal"
8-
gem "bundler-audit"
9-
gem "childprocess"
10-
gem "climate_control"
11-
gem "pry-byebug", platform: :mri
12-
gem "pry-nav", platform: :jruby
13-
gem "rake"
14-
gem "prettier_print"
15-
gem "syntax_tree"
16-
gem "syntax_tree-haml"
17-
gem "syntax_tree-rbs"
18-
gem "warnings_logger"
7+
gem 'appraisal', github: 'thoughtbot/appraisal'
8+
gem 'bundler-audit'
9+
gem 'childprocess'
10+
gem 'climate_control'
11+
gem 'prettier_print'
12+
gem 'pry-byebug', platform: :mri
13+
gem 'pry-nav', platform: :jruby
14+
gem 'rake'
15+
gem 'rubocop'
16+
gem 'syntax_tree'
17+
gem 'syntax_tree-haml'
18+
gem 'syntax_tree-rbs'
19+
gem 'warnings_logger'
1920

2021
gemspec

0 commit comments

Comments
 (0)