Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve RuboCop offenses #534

Merged
merged 22 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3be4f0b
Simple RuboCop fixes
AlexWayfer Aug 23, 2023
0d1e042
Add `max_line_length` into EditorConfig
AlexWayfer Aug 23, 2023
dbcd27f
Remove RuboCop config file from `.gitignore`
AlexWayfer Aug 23, 2023
df80c84
Breaking changes with optional arguments
AlexWayfer Aug 23, 2023
ee6ac8b
Add Changelog entries
AlexWayfer Aug 23, 2023
79dfb19
Merge branch 'main' into resolve_rubocop_offenses
AlexWayfer Aug 23, 2023
686314a
Fix error with `Image.file`
AlexWayfer Aug 23, 2023
66dfa3e
Resolve RuboCop offense about global variable
AlexWayfer Aug 23, 2023
229390b
Replace manual `autoload` list with dynamic one
AlexWayfer Aug 23, 2023
fd1c67c
Resolve RuboCop offense about block length in `scripts/reference`
AlexWayfer Aug 23, 2023
31c8d3d
Add `.rubocop_todo` file
AlexWayfer Aug 23, 2023
1887547
Add `rubocop-performance` and `rubocop-rake` gems
AlexWayfer Aug 23, 2023
9e6c270
Add `inherit_mode` for RuboCop config
AlexWayfer Aug 23, 2023
1b4b79e
Resolve Ruby warning about `-` char in Regex
AlexWayfer Aug 23, 2023
79c3c7d
Add RuboCop GitHub Action
AlexWayfer Aug 23, 2023
f773f9a
Add `bundle exec` for GitHub Actions
AlexWayfer Aug 23, 2023
f73467f
Merge branch 'main' into resolve_rubocop_offenses
AlexWayfer Sep 10, 2023
420680d
Rename `autoload_abbreviations` into `autoload_acronyms`
AlexWayfer Sep 10, 2023
48228e9
Resolve a new RuboCop offense
AlexWayfer Sep 10, 2023
78e3d52
Add file exclusions for `Style/AsciiComments` RuboCop cop
AlexWayfer Sep 10, 2023
4a08631
Revert breaking changes, return positional arguments
AlexWayfer Sep 11, 2023
25c3812
Merge branch 'main' into resolve_rubocop_offenses
marocchino Sep 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120
17 changes: 17 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: RuboCop
on:
pull_request:
push:
branches:
- "main"
jobs:
test:
runs-on: ubuntu-latest
name: RuboCop lint
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 'ruby'
bundler-cache: true # 'bundle install' and cache
- run: bundle exec rake rubocop
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true # 'bundle install' and cache
- run: rake test
- run: bundle exec rake test
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ Gemfile.lock
.ruby-gemset
.ruby-version
.rvmrc
.rubocop.yml
28 changes: 25 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
require:
- rubocop-performance
- rubocop-rake

inherit_mode:
merge:
- Include
- Exclude

inherit_from:
- ./.rubocop_todo.yml

AllCops:
TargetRubyVersion: 3.0
NewCops: enable
Expand All @@ -24,13 +36,23 @@ Style/Documentation:
Style/AsciiComments:
Enabled: true
Exclude:
- 'lib/ffaker/address_ja.rb'
- 'lib/ffaker/address_se.rb'
- '**/*_cs.rb'
- '**/*_ja.rb'
- '**/*_mx.rb'
- '**/*_se.rb'
Style/OptionalBooleanParameter:
Enabled: false
Metrics/ModuleLength:
Enabled: true
Max: 200
Metrics/ClassLength:
Exclude:
- 'lib/ffaker/bank.rb'
- 'test/**/*.rb'
Metrics/MethodLength:
AllowedPatterns:
- 'test_'
Metrics/AbcSize:
AllowedPatterns:
- 'test_'
Style/RedundantArgument:
Enabled: false
6 changes: 6 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Metrics/MethodLength:
Enabled: false
Metrics/AbcSize:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## development

- Add your change HERE
- Resolve a lot of RuboCop offenses [@AlexWayfer]
- Change `Image.url`, `Image.file`, `Book.cover` and `Avatar.image` arguments to keywords [@AlexWayfer]
- Adds FFaker::Date.birthday [@professor]
- Adds FFaker::Crypto.sha256 [@professor]
- Update README [@professor]
Expand Down
15 changes: 15 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec

group :development do
gem 'rake', '~> 13.0'
end

group :development, :lint do
gem 'rubocop'
gem 'rubocop-performance'
gem 'rubocop-rake'
end

group :development, :test do
gem 'test-unit'
end
4 changes: 2 additions & 2 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
* [FFaker::IdentificationESCO](#ffakeridentificationesco)
* [FFaker::IdentificationIN](#ffakeridentificationin)
* [FFaker::IdentificationIT](#ffakeridentificationit)
* [FFaker::IdentificationKr](#ffakeridentificationkr)
* [FFaker::IdentificationKR](#ffakeridentificationkr)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change. I think it was an error.

* [FFaker::IdentificationMX](#ffakeridentificationmx)
* [FFaker::IdentificationPL](#ffakeridentificationpl)
* [FFaker::IdentificationTW](#ffakeridentificationtw)
Expand Down Expand Up @@ -1385,7 +1385,7 @@
| `gender` | ‼️ FFaker::UniqueUtils::RetryLimitExceeded: Retry limit exceeded for gender |
| `ssn` | 11830877014613103430, 45436375172610549922, 29278264986997805738 |

## FFaker::IdentificationKr
## FFaker::IdentificationKR

| Method | Example |
| ------ | ------- |
Expand Down
14 changes: 7 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ module Test
end
end

require 'rubocop/rake_task'

RuboCop::RakeTask.new

#############################################################################
#
# Helper functions
Expand Down Expand Up @@ -80,14 +84,9 @@ rescue LoadError
end
end

#############################################################################
#
# Packaging tasks
#
#############################################################################

desc 'Packaging tasks'
task release: :build do
unless `git branch` =~ /^\* main$/
unless `git branch`.match?(/^\* main$/)
puts 'You must be on the main branch to release!'
exit!
end
Expand All @@ -103,6 +102,7 @@ task build: %i[validate reference] do
sh "gem build #{gemspec_file} --output=pkg/#{gem_file}"
end

desc 'Validate library files'
task :validate do
libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
unless libfiles.empty?
Expand Down
8 changes: 2 additions & 6 deletions ffaker.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,12 @@ Gem::Specification.new do |s|
s.files = `git ls-files`
.split("\n")
.sort
.reject { |file| file =~ /^\./ }
.reject { |file| file =~ /^(rdoc|pkg)/ }
.grep_v(/^\./)
.grep_v(/^(rdoc|pkg)/)

s.metadata = {
'changelog_uri' => 'https://github.com/ffaker/ffaker/blob/main/Changelog.md',
'documentation_uri' => 'https://github.com/ffaker/ffaker/blob/main/REFERENCE.md',
'rubygems_mfa_required' => 'true'
}

s.add_development_dependency 'rake', '~> 13.0'
s.add_development_dependency 'rubocop'
s.add_development_dependency 'test-unit'
end