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

Enable rubocop locally and on ci #390

Merged
merged 1 commit into from Dec 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Expand Up @@ -8,6 +8,19 @@ on:
branches:
- "*"
jobs:
lint:
name: RuboCop
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.4"
bundler-cache: true
- name: Run RuboCop
run: bundle exec rubocop
test:
strategy:
fail-fast: false
Expand Down
27 changes: 13 additions & 14 deletions .rubocop.yml
@@ -1,20 +1,15 @@
AllCops:
Exclude:
- 'bin/**/*'
- 'db/**/*'
- 'config/**/*'
- 'script/**/*'
inherit_from: .rubocop_todo.yml

Style/AlignParameters:
Layout/AlignParameters:
EnforcedStyle: with_fixed_indentation

Style/CaseIndentation:
Layout/CaseIndentation:
EnforcedStyle: end

Style/AsciiComments:
Enabled: false

Style/IndentHash:
Layout/IndentHash:
Enabled: false

Style/CollectionMethods:
Expand All @@ -39,7 +34,7 @@ Style/GuardClause:
Style/IfUnlessModifier:
Enabled: false

Style/SpaceInsideHashLiteralBraces:
Layout/SpaceInsideHashLiteralBraces:
Enabled: false

Style/Lambda:
Expand All @@ -55,14 +50,18 @@ Metrics/AbcSize:
Max: 20

Metrics/ClassLength:
Max: 100
Max: 101

Metrics/ModuleLength:
Max: 100

Metrics/LineLength:
Enabled: false

Metrics/BlockLength:
Exclude:
- spec/**/*_spec.rb

Metrics/MethodLength:
Max: 15

Expand All @@ -75,10 +74,10 @@ Lint/EndAlignment:
Style/FormatString:
Enabled: false

Style/MultilineMethodCallIndentation:
Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented

Style/MultilineOperationIndentation:
Layout/MultilineOperationIndentation:
EnforcedStyle: indented

Style/WordArray:
Expand All @@ -87,7 +86,7 @@ Style/WordArray:
Style/RedundantSelf:
Enabled: false

Style/AlignHash:
Layout/AlignHash:
Enabled: true
EnforcedLastArgumentHashStyle: always_ignore

Expand Down
190 changes: 190 additions & 0 deletions .rubocop_todo.yml
@@ -0,0 +1,190 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-12-21 23:11:43 +0200 using RuboCop version 0.52.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: Include, TreatCommentsAsGroupSeparators.
# Include: **/*.gemspec
Gemspec/OrderedDependencies:
Exclude:
- 'ruby-jwt.gemspec'

# Offense count: 1
# Cop supports --auto-correct.
Layout/EmptyLines:
Exclude:
- 'spec/integration/readme_examples_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, no_empty_lines
Layout/EmptyLinesAroundBlockBody:
Exclude:
- 'spec/jwt_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
Layout/ExtraSpacing:
Exclude:
- 'spec/jwk_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: normal, rails
Layout/IndentationConsistency:
Exclude:
- 'spec/jwt_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns.
Layout/IndentationWidth:
Exclude:
- 'spec/jwt_spec.rb'

# Offense count: 3
# Cop supports --auto-correct.
Layout/SpaceAfterComma:
Exclude:
- 'spec/jwt_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
# SupportedStyles: space, no_space
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceBeforeBlockBraces:
Exclude:
- 'spec/jwk/ec_spec.rb'
- 'spec/jwt/verify_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
# SupportedStyles: space, no_space
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceInsideBlockBraces:
Exclude:
- 'spec/jwt/verify_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: final_newline, final_blank_line
Layout/TrailingBlankLines:
Exclude:
- 'bin/console.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
Lint/UnusedBlockArgument:
Exclude:
- 'spec/jwk/decode_with_jwk_spec.rb'
- 'spec/jwk/ec_spec.rb'
- 'spec/jwt/verify_spec.rb'

# Offense count: 2
Metrics/CyclomaticComplexity:
Max: 7

# Offense count: 1
Metrics/PerceivedComplexity:
Max: 8

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: MaxKeyValuePairs.
Performance/RedundantMerge:
Exclude:
- 'spec/jwt_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/Encoding:
Exclude:
- 'lib/jwt/version.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: InverseMethods, InverseBlocks.
Style/InverseMethods:
Exclude:
- 'spec/jwk/ec_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
Style/MethodCallWithoutArgsParentheses:
Exclude:
- 'spec/jwt_spec.rb'

# Offense count: 1
# Configuration parameters: EnforcedStyle.
# SupportedStyles: module_function, extend_self
Style/ModuleFunction:
Exclude:
- 'lib/jwt/signature.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/MultilineIfModifier:
Exclude:
- 'spec/integration/readme_examples_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/MutableConstant:
Exclude:
- 'lib/jwt/version.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: Strict.
Style/NumericLiterals:
MinDigits: 6

# Offense count: 1
# Cop supports --auto-correct.
Style/ParallelAssignment:
Exclude:
- 'spec/integration/readme_examples_spec.rb'

# Offense count: 11
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'bin/console.rb'
- 'spec/jwk/ec_spec.rb'
- 'spec/jwk/rsa_spec.rb'
- 'spec/jwk_spec.rb'
- 'spec/jwt_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInArguments:
Exclude:
- 'spec/jwt_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/UnlessElse:
Exclude:
- 'spec/jwt_spec.rb'

# Offense count: 162
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 420
2 changes: 2 additions & 0 deletions Gemfile
@@ -1,3 +1,5 @@
source 'https://rubygems.org'

gemspec

gem 'rubocop', '~> 0.52.0' # Same as codeclimate default
2 changes: 1 addition & 1 deletion lib/jwt/jwk/rsa.rb
Expand Up @@ -90,7 +90,7 @@ def populate_key(rsa_key, rsa_parameters)
rsa_key
end
else
def populate_key(rsa_key, rsa_parameters) # rubocop:disable Metrics/CyclomaticComplexity
def populate_key(rsa_key, rsa_parameters)
rsa_key.n = rsa_parameters[:n]
rsa_key.e = rsa_parameters[:e]
rsa_key.d = rsa_parameters[:d] if rsa_parameters[:d]
Expand Down
2 changes: 1 addition & 1 deletion spec/jwt/verify_spec.rb
Expand Up @@ -3,7 +3,7 @@
require 'spec_helper'
require 'jwt/verify'

module JWT
module JWT # rubocop:disable Metrics/ModuleLength
RSpec.describe Verify do
let(:base_payload) { { 'user_id' => 'some@user.tld' } }
let(:options) { { leeway: 0 } }
Expand Down