Skip to content

Commit

Permalink
Upgrade the codebase to Rubocop 1.22 and use config from `rubocop-bri…
Browse files Browse the repository at this point in the history
…dgetown` gem
  • Loading branch information
jaredcwhite committed Oct 16, 2021
1 parent 4fc5934 commit 4182c8d
Show file tree
Hide file tree
Showing 104 changed files with 512 additions and 629 deletions.
118 changes: 5 additions & 113 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
inherit_from: .rubocop_todo.yml

require:
- rubocop-performance
- rubocop-bridgetown
- ./rubocop/bridgetown

inherit_gem:
rubocop-bridgetown: .rubocop.yml

Bridgetown/NoPutsAllowed:
Exclude:
- rake/*.rake
Expand All @@ -14,57 +17,23 @@ Bridgetown/NoPutsAllowed:

AllCops:
TargetRubyVersion: 2.5
Include:
- bridgetown-core/lib/**/*.rb
- bridgetown-core/test/**/*.rb
Exclude:
- bridgetown-core/bin/**/*
- bridgetown-core/exe/**/*
- bridgetown-core/benchmark/**/*
- bridgetown-core/script/**/*
- bridgetown-core/vendor/**/*
- bridgetown-core/tmp/**/*
- bridgetown-core/lib/site_template/config/**/*
- bridgetown-core/lib/site_template/plugins/site_builder.rb
Layout/HashAlignment:
EnforcedHashRocketStyle: table
Layout/IndentationWidth:
Severity: error
Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent
Layout/FirstHashElementIndentation:
EnforcedStyle: consistent
Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented
Layout/MultilineOperationIndentation:
EnforcedStyle: indented

Lint/NestedPercentLiteral:
Exclude:
- bridgetown-core/test/test_site.rb
Layout/EmptyComment:
Enabled: false
Layout/EndAlignment:
Severity: error
Lint/RaiseException:
Enabled: true
Lint/RescueException:
Exclude:
- bridgetown-core/lib/bridgetown-core/watcher.rb
Lint/StructNewOverride:
Enabled: true
Lint/SuppressedException:
Exclude:
- bridgetown-core/lib/bridgetown-core/commands/new.rb
Lint/UnreachableCode:
Severity: error
Lint/UnusedBlockArgument:
Exclude:
- bridgetown-core/lib/site_template/**/*.rb
Lint/Void:
Exclude:
- bridgetown-core/lib/bridgetown-core/concerns/site/configurable.rb
Metrics/AbcSize:
Max: 24
Exclude:
- bridgetown-core/lib/bridgetown-core/commands/build.rb
- bridgetown-core/lib/bridgetown-core/commands/new.rb
Expand All @@ -81,10 +50,8 @@ Metrics/ClassLength:
Exclude:
- !ruby/regexp /bridgetown-core/features\/.*.rb$/
- !ruby/regexp /bridgetown-core/test\/.*.rb$/
- bridgetown-core/lib/bridgetown-core/document.rb
- bridgetown-core/lib/bridgetown-core/commands/serve.rb
- bridgetown-core/lib/bridgetown-core/configuration.rb
Max: 240
Metrics/CyclomaticComplexity:
Exclude:
- bridgetown-core/lib/bridgetown-core/utils.rb
Expand All @@ -99,12 +66,7 @@ Layout/LineLength:
- bridgetown-core/Rakefile
- bridgetown-core/rake/*.rake
- Gemfile
Max: 100
Severity: warning
Metrics/MethodLength:
CountComments: false
Max: 20
Severity: error
Exclude:
- bridgetown-core/lib/bridgetown-core/commands/concerns/build_options.rb
- bridgetown-core/lib/bridgetown-core/commands/build.rb
Expand All @@ -113,109 +75,39 @@ Metrics/MethodLength:
- bridgetown-core/lib/bridgetown-core/commands/plugins.rb
- bridgetown-core/lib/bridgetown-core/commands/start.rb
Metrics/ModuleLength:
Max: 240
Exclude:
- bridgetown-core/lib/bridgetown-core/filters.rb
Metrics/ParameterLists:
Max: 4
Exclude:
- bridgetown-core/lib/bridgetown-core/hooks.rb
Metrics/PerceivedComplexity:
Max: 8
Exclude:
- bridgetown-core/lib/bridgetown-core/commands/build.rb
- bridgetown-core/lib/bridgetown-core/commands/plugins.rb
Naming/FileName:
Enabled: false
Naming/HeredocDelimiterNaming:
Exclude:
- bridgetown-core/test/**/*.rb
Naming/MemoizedInstanceVariableName:
Enabled: false
Security/MarshalLoad:
Exclude:
- !ruby/regexp /bridgetown-core/test\/.*.rb$/
Security/YAMLLoad:
Exclude:
- !ruby/regexp /bridgetown-core/features\/.*.rb/
- !ruby/regexp /bridgetown-core/test\/.*.rb$/
Style/AccessModifierDeclarations:
Enabled: false
Style/Alias:
EnforcedStyle: prefer_alias_method
Style/AndOr:
Severity: error
Style/ClassAndModuleChildren:
Exclude:
- bridgetown-core/lib/bridgetown-core/concerns/site/*.rb
- bridgetown-core/test/**/*.rb
Style/FrozenStringLiteralComment:
EnforcedStyle: always
Exclude:
- bridgetown-core/lib/site_template/**/*.rb
Style/Documentation:
Enabled: false
Style/DoubleNegation:
Enabled: false
Style/FormatStringToken:
Exclude:
- bridgetown-core/lib/bridgetown-core/utils/ansi.rb
- bridgetown-core/lib/bridgetown-core/liquid_renderer/table.rb
Style/GlobalVars:
Exclude:
- bridgetown-core/lib/bridgetown-core/commands/console.rb
Style/GuardClause:
Enabled: false
Style/HashEachMethods:
Enabled: true
Style/HashSyntax: # This now adheres to GitHub's newest Ruby style guide
EnforcedStyle: ruby19
SupportedStyles:
# checks for 1.9 syntax (e.g. {a: 1}) for all symbol keys
- ruby19
# checks for hash rocket syntax for all hashes
- hash_rockets
# forbids mixed key syntaxes (e.g. {a: 1, :b => 2})
- no_mixed_keys
# enforces both ruby19 and no_mixed_keys styles
- ruby19_no_mixed_keys
# Force hashes that have a symbol value to use hash rockets
UseHashRocketsWithSymbolValues: false
# Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style
PreferHashRocketsForNonAlnumEndingSymbols: false
Style/HashTransformKeys:
Enabled: false
Style/HashTransformValues:
Enabled: true
Style/Lambda:
EnforcedStyle: literal
Style/LambdaCall:
Enabled: false
Style/MixinUsage:
Exclude:
- bridgetown-core/test/helper.rb
Style/ModuleFunction:
Enabled: false
Style/MultilineTernaryOperator:
Severity: error
Style/PercentLiteralDelimiters:
Enabled: false
Style/RegexpLiteral:
EnforcedStyle: percent_r
Style/RescueModifier:
Enabled: false
Style/SafeNavigation:
Exclude:
- bridgetown-core/lib/bridgetown-core/document.rb
Style/SignalException:
EnforcedStyle: only_raise
Style/StringLiterals:
EnforcedStyle: double_quotes
Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes
Style/SymbolArray:
Enabled: false
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: consistent_comma
Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: consistent_comma
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

...

## 1.0.0.alpha2 - 2021-10-15

* Upgrade the codebase to Rubocop 1.22 and use config from `rubocop-bridgetown` gem

## 1.0.0.alpha1 - 2021-10-15

**NOTE:** this is still considered experimental and largely undocumented.
Expand Down
5 changes: 2 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ group :test do
gem "nokogiri", "~> 1.7"
gem "rspec"
gem "rspec-mocks"
gem "rubocop", "~> 0.81.0"
gem "rubocop-performance"
gem "rubocop-bridgetown", "~> 0.3.0", require: false
gem "shoulda"
gem "simplecov"
end
Expand All @@ -40,7 +39,7 @@ group :bridgetown_optional_dependencies do
end

# Bridgetown
gem "bridgetown", path: "bridgetown"
gem "bridgetown-builder", path: "bridgetown-builder"
gem "bridgetown-core", path: "bridgetown-core"
gem "bridgetown-paginate", path: "bridgetown-paginate"
gem "bridgetown", path: "bridgetown"
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ task :test_all do
sh "cd bridgetown-core && script/cibuild"
sh "cd bridgetown-builder && script/cibuild"
sh "cd bridgetown-paginate && script/cibuild"
sh "cd bridgetown-routes && script/cibuild"
end

task :release_all_unsafe do
sh "cd bridgetown-core && bundle exec rake release"
sh "cd bridgetown-builder && bundle exec rake release"
sh "cd bridgetown-paginate && bundle exec rake release"
sh "cd bridgetown-routes && bundle exec rake release"
sh "cd bridgetown && bundle exec rake release"
end

Expand Down
5 changes: 3 additions & 2 deletions bridgetown-builder/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
inherit_from: ../.rubocop.yml

AllCops:
Include:
- lib/**/*.rb
Exclude:
- "*.gemspec"
- test/**/*.rb

Metrics/AbcSize:
Exclude:
Expand Down
3 changes: 2 additions & 1 deletion bridgetown-builder/lib/bridgetown-builder/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def inspect
end

def self.descendants
super.reject { |klass| ["SiteBuilder"].include?(klass.name) }
site_builder_name = "SiteBuilder"
super.reject { |klass| [site_builder_name].include?(klass.name) }
end
end
end
16 changes: 8 additions & 8 deletions bridgetown-builder/lib/bridgetown-builder/dsl/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ module DSL
module HTTP
def get(url, headers: {}, parse_json: true)
body = begin
connection(parse_json: parse_json).get(url, headers: headers).body
rescue Faraday::ParsingError
Bridgetown.logger.error(
"Faraday::ParsingError",
"The response from #{url} did not contain valid JSON"
)
nil
end
connection(parse_json: parse_json).get(url, headers: headers).body
rescue Faraday::ParsingError
Bridgetown.logger.error(
"Faraday::ParsingError",
"The response from #{url} did not contain valid JSON"
)
nil
end
yield body
end

Expand Down
2 changes: 1 addition & 1 deletion bridgetown-builder/lib/bridgetown-builder/dsl/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Bridgetown
module Builders
module DSL
module Resources
def add_resource(collection_name, path, &block)
def add_resource(collection_name, path, &block) # rubocop:todo Metrics/AbcSize
data = Bridgetown::Utils::RubyFrontMatter.new(scope: self).tap do |fm|
fm.define_singleton_method(:___) do |hsh|
hsh.each do |k, v|
Expand Down
35 changes: 35 additions & 0 deletions bridgetown-core/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
inherit_from: ../.rubocop.yml

AllCops:
Exclude:
- "*.gemspec"
- bin/**/*
- exe/**/*
- benchmark/**/*
- script/**/*
- vendor/**/*
- tmp/**/*
- test/source/**/*
- lib/site_template/Rakefile
- lib/site_template/config.ru
- lib/site_template/config/**/*
- lib/site_template/plugins/site_builder.rb

Lint/ConstantDefinitionInBlock:
Exclude:
- test/test_filters.rb
- test/test_liquid_extensions.rb
- test/test_site.rb

Lint/MissingSuper:
Exclude:
- test/test_liquid_extensions.rb

Performance/CollectionLiteralInLoop:
Exclude:
- test/test_filters.rb

Style/StringConcatenation:
Exclude:
- test/test_apply_command.rb
10 changes: 5 additions & 5 deletions bridgetown-core/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ Rake::TestTask.new(:test) do |test|
test.verbose = true
end

require 'yard'
require "yard"
YARD::Rake::YardocTask.new(:yard) do |t|
t.files = ['lib/**/*.rb']
t.options = ['--no-output']
t.stats_options = ['--list-undoc']
t.files = ["lib/**/*.rb"]
t.options = ["--no-output"]
t.stats_options = ["--list-undoc"]
end

namespace :yard do
task :serve do
port = ENV['YARD_PORT'] || "8808"
port = ENV["YARD_PORT"] || "8808"
sh("yard server --reload -p #{port}")
end
end
Loading

0 comments on commit 4182c8d

Please sign in to comment.