-
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
Add rubocop #102
Merged
Merged
Add rubocop #102
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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,123 @@ | ||
# The behavior of RuboCop can be controlled via the .rubocop.yml | ||
# configuration file. It makes it possible to enable/disable | ||
# certain cops (checks) and to alter their behavior if they accept | ||
# any parameters. The file can be placed either in your home | ||
# directory or in some project directory. | ||
# | ||
# RuboCop will start looking for the configuration file in the directory | ||
# where the inspected file is and continue its way up to the root directory. | ||
# | ||
# See https://docs.rubocop.org/rubocop/configuration | ||
AllCops: | ||
NewCops: enable | ||
Exclude: | ||
- vendor/bundle/**/** | ||
TargetRubyVersion: 2.6 | ||
|
||
Metrics/ParameterLists: | ||
Enabled: false | ||
|
||
# This cop is annoying with typed configuration | ||
Style/TrivialAccessors: | ||
Enabled: false | ||
|
||
# This rubocop is annoying when we use interfaces a lot | ||
Lint/UnusedMethodArgument: | ||
Enabled: false | ||
|
||
Gemspec/RequireMFA: | ||
Enabled: false | ||
|
||
Lint/DuplicateBranch: | ||
Enabled: false | ||
|
||
# If is sometimes easier to think about than unless sometimes | ||
Style/NegatedIf: | ||
Enabled: false | ||
|
||
# Disabling for now until it's clearer why we want this | ||
Style/FrozenStringLiteralComment: | ||
Enabled: false | ||
|
||
# It's nice to be able to read the condition first before reading the code within the condition | ||
Style/GuardClause: | ||
Enabled: false | ||
|
||
# | ||
# Leaving length metrics to human judgment for now | ||
# | ||
Metrics/ModuleLength: | ||
Enabled: false | ||
|
||
Layout/LineLength: | ||
Enabled: false | ||
|
||
Metrics/BlockLength: | ||
Enabled: false | ||
|
||
Metrics/MethodLength: | ||
Enabled: false | ||
|
||
Metrics/AbcSize: | ||
Enabled: false | ||
|
||
Metrics/ClassLength: | ||
Enabled: false | ||
|
||
# This doesn't feel useful | ||
Metrics/CyclomaticComplexity: | ||
Enabled: false | ||
|
||
# This doesn't feel useful | ||
Metrics/PerceivedComplexity: | ||
Enabled: false | ||
|
||
# It's nice to be able to read the condition first before reading the code within the condition | ||
Style/IfUnlessModifier: | ||
Enabled: false | ||
|
||
# This leads to code that is not very readable at times (very long lines) | ||
Style/ConditionalAssignment: | ||
Enabled: false | ||
|
||
# For now, we prefer to lean on clean method signatures as documentation. We may change this later. | ||
Style/Documentation: | ||
Enabled: false | ||
|
||
# Sometimes we leave comments in empty else statements intentionally | ||
Style/EmptyElse: | ||
Enabled: false | ||
|
||
# Sometimes we want to more explicitly list out a condition | ||
Style/RedundantCondition: | ||
Enabled: false | ||
|
||
# This leads to code that is not very readable at times (very long lines) | ||
Layout/MultilineMethodCallIndentation: | ||
Enabled: false | ||
|
||
# Blocks across lines are okay sometimes | ||
Style/BlockDelimiters: | ||
Enabled: false | ||
|
||
# Sometimes we like methods like `get_packages` | ||
Naming/AccessorMethodName: | ||
Enabled: false | ||
|
||
# This leads to code that is not very readable at times (very long lines) | ||
Layout/FirstArgumentIndentation: | ||
Enabled: false | ||
|
||
# This leads to code that is not very readable at times (very long lines) | ||
Layout/ArgumentAlignment: | ||
Enabled: false | ||
|
||
Style/AccessorGrouping: | ||
Enabled: false | ||
|
||
Style/HashSyntax: | ||
Enabled: false | ||
|
||
Gemspec/DevelopmentDependencies: | ||
Enabled: true | ||
EnforcedStyle: gemspec |
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 |
---|---|---|
|
@@ -14,7 +14,7 @@ def self.run!(argv) | |
for_file(argv) | ||
elsif command == 'for_team' | ||
for_team(argv) | ||
elsif [nil, "help"].include?(command) | ||
elsif [nil, 'help'].include?(command) | ||
puts <<~USAGE | ||
Usage: bin/codeownership <subcommand> | ||
|
||
|
@@ -27,7 +27,6 @@ def self.run!(argv) | |
else | ||
puts "'#{command}' is not a code_ownership command. See `bin/codeownership help`." | ||
end | ||
|
||
end | ||
|
||
def self.validate!(argv) | ||
|
@@ -53,16 +52,16 @@ def self.validate!(argv) | |
exit | ||
end | ||
end | ||
args = parser.order!(argv) {} | ||
args = parser.order!(argv) | ||
parser.parse!(args) | ||
|
||
files = if options[:diff] | ||
ENV.fetch('CODEOWNERS_GIT_STAGED_FILES') { `git diff --staged --name-only` }.split("\n").select do |file| | ||
File.exist?(file) | ||
end | ||
else | ||
nil | ||
end | ||
ENV.fetch('CODEOWNERS_GIT_STAGED_FILES') { `git diff --staged --name-only` }.split("\n").select do |file| | ||
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. white space 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. 🏃♀️💨 |
||
File.exist?(file) | ||
end | ||
else | ||
nil | ||
end | ||
|
||
CodeOwnership.validate!( | ||
files: files, | ||
|
@@ -79,7 +78,7 @@ def self.for_file(argv) | |
# Long-term, we probably want to use something like `thor` so we don't have to implement logic | ||
# like this. In the short-term, this is a simple way for us to use the built-in OptionParser | ||
# while having an ergonomic CLI. | ||
files = argv.select { |arg| !arg.start_with?('--') } | ||
files = argv.reject { |arg| arg.start_with?('--') } | ||
|
||
parser = OptionParser.new do |opts| | ||
opts.banner = 'Usage: bin/codeownership for_file [options]' | ||
|
@@ -93,22 +92,22 @@ def self.for_file(argv) | |
exit | ||
end | ||
end | ||
args = parser.order!(argv) {} | ||
args = parser.order!(argv) | ||
parser.parse!(args) | ||
|
||
if files.count != 1 | ||
raise "Please pass in one file. Use `bin/codeownership for_file --help` for more info" | ||
raise 'Please pass in one file. Use `bin/codeownership for_file --help` for more info' | ||
end | ||
|
||
team = CodeOwnership.for_file(files.first) | ||
|
||
team_name = team&.name || "Unowned" | ||
team_yml = team&.config_yml || "Unowned" | ||
team_name = team&.name || 'Unowned' | ||
team_yml = team&.config_yml || 'Unowned' | ||
|
||
if options[:json] | ||
json = { | ||
team_name: team_name, | ||
team_yml: team_yml, | ||
team_yml: team_yml | ||
} | ||
|
||
puts json.to_json | ||
|
@@ -121,8 +120,6 @@ def self.for_file(argv) | |
end | ||
|
||
def self.for_team(argv) | ||
options = {} | ||
|
||
parser = OptionParser.new do |opts| | ||
opts.banner = 'Usage: bin/codeownership for_team \'Team Name\'' | ||
|
||
|
@@ -131,14 +128,14 @@ def self.for_team(argv) | |
exit | ||
end | ||
end | ||
teams = argv.select { |arg| !arg.start_with?('--') } | ||
args = parser.order!(argv) {} | ||
teams = argv.reject { |arg| arg.start_with?('--') } | ||
args = parser.order!(argv) | ||
parser.parse!(args) | ||
|
||
if teams.count != 1 | ||
raise "Please pass in one team. Use `bin/codeownership for_team --help` for more info" | ||
raise 'Please pass in one team. Use `bin/codeownership for_team --help` for more info' | ||
end | ||
|
||
puts CodeOwnership.for_team(teams.first) | ||
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.
What's with all the white space?
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 know 🤖