-
Notifications
You must be signed in to change notification settings - Fork 25
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
Set up Rubocop for the template #320
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
97c742c
Setup rubocop and fix warnings
rosle eb66d95
Add template rubocop script
rosle bf920c8
Fix rubocop warnings and adjust rubocop config
rosle 59787bf
wip
rosle 203b26b
Fix failed tests
rosle 11ff233
Update readme
rosle b337ddf
Revert workflow trigger
rosle 4a6596d
Update readme
rosle 25f0dc4
Update target ruby version to 3
rosle f502949
Update readme
rosle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
BUNDLE_GEMFILE: ".template/Gemfile" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Test Template | ||
|
||
on: push | ||
|
||
env: | ||
RUBY_VERSION: 3.0.1 | ||
|
||
jobs: | ||
test: | ||
name: Test template | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Cancel previous runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- name: Checkout Repository | ||
uses: actions/[email protected] | ||
|
||
- name: Setup Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ env.RUBY_VERSION }} | ||
bundler-cache: true | ||
|
||
- name: Cache gems | ||
uses: actions/cache@v2 | ||
with: | ||
path: vendor/bundle | ||
key: ${{ runner.os }}-template-${{ env.RUBY_VERSION }}-${{ hashFiles('**/Gemfile.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-template-${{ env.RUBY_VERSION }}- | ||
|
||
- name: Install gems | ||
run: | | ||
bundle config path vendor/bundle | ||
bundle install --jobs 4 --retry 3 | ||
|
||
- name: Run RuboCop | ||
run: bundle exec rubocop --config .template/.rubocop.yml --parallel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
AllCops: | ||
NewCops: enable | ||
TargetRubyVersion: 3 | ||
Exclude: | ||
- 'vendor/**/*' | ||
|
||
Lint/NonDeterministicRequireOrder: | ||
Exclude: | ||
- '../spec/rails_helper.rb' | ||
|
||
Metrics/MethodLength: | ||
Exclude: | ||
- '../template.rb' | ||
- '**/template.rb' | ||
- 'hooks/**/*' | ||
|
||
Metrics/AbcSize: | ||
Enabled: false | ||
|
||
Metrics/BlockLength: | ||
Enabled: false | ||
|
||
Metrics/CyclomaticComplexity: | ||
Exclude: | ||
- '../template.rb' | ||
- '**/template.rb' | ||
|
||
Metrics/PerceivedComplexity: | ||
Exclude: | ||
- '../template.rb' | ||
- '**/template.rb' | ||
|
||
Naming/FileName: | ||
Enabled: false | ||
|
||
Style/Documentation: | ||
Enabled: false | ||
|
||
Style/FrozenStringLiteralComment: | ||
Enabled: false | ||
|
||
# TODO: Enable this rule later | ||
Style/GlobalVars: | ||
Enabled: false | ||
|
||
# TODO: Enable this rule later | ||
Style/RegexpLiteral: | ||
Enabled: false | ||
|
||
Style/TrivialAccessors: | ||
Exclude: | ||
- '../template.rb' | ||
- '**/template.rb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'docker-api' # A lightweight Ruby client for the Docker Remote API | ||
gem 'rspec' # BDD for Ruby | ||
gem 'rspec-wait' # Wait for conditions in RSpec | ||
gem 'rubocop', require: false # A Ruby static code analyzer and formatter, based on the community Ruby style guide. | ||
gem 'serverspec' # RSpec tests for your servers | ||
gem 'docker-api' # A lightweight Ruby client for the Docker Remote API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
after_bundle do | ||
use_source_path __dir__ | ||
|
||
copy_file '.phraseapp.yml' | ||
apply 'spec/template.rb' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
bundle exec rubocop --config .template/.rubocop.yml $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# rubocop:todo Style/ClassAndModuleChildren | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll fix this when working on refactoring the template - #321. Because it needs to load the template module in prior. 🙏 |
||
class Template::Errors < Template::Messages; end | ||
# rubocop:enable Style/ClassAndModuleChildren |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.template/spec/base/app/controllers/concerns/localization_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
append_to_file '.gitignore' do | ||
<<~IGNORE | ||
# Ignore i18n.js generated files | ||
# If deploy to heroku with git, please remove this as it prevents the files to be committed | ||
/app/javascript/translations/* | ||
# Ignore i18n.js generated files | ||
# If deploy to heroku with git, please remove this as it prevents the files to be committed | ||
/app/javascript/translations/* | ||
|
||
# Ignore asset builds | ||
/app/assets/builds/* | ||
# Ignore asset builds | ||
/app/assets/builds/* | ||
|
||
# Ignore Node dependencies | ||
/node_modules | ||
# Ignore Node dependencies | ||
/node_modules | ||
IGNORE | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll enable these rules later in another PR, so this PR is not too big. 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rosle , here are two of my favorites cops:
Is this something we could incorporate, what do you think? Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted. I'll open more PRs to fix these cops and I'll revisit those rules 👍 ✨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tyrro I revisited these 2 cops, seems we already have it enabled 👍 🚀