Skip to content

Commit

Permalink
[CLEANUP] Fix autofixable RuboCop warnings (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverklee authored Feb 18, 2022
1 parent f16a255 commit 80a1e8c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 67 deletions.
62 changes: 5 additions & 57 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2022-02-18 18:32:24 UTC using RuboCop version 1.25.1.
# on 2022-02-18 18:35:17 UTC using RuboCop version 1.25.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: 1
# Cop supports --auto-correct.
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
# Include: **/*.gemspec
Gemspec/OrderedDependencies:
Exclude:
- 'page_title_helper.gemspec'

# Offense count: 1
# Cop supports --auto-correct.
Layout/EmptyLineAfterMagicComment:
Exclude:
- 'page_title_helper.gemspec'

# Offense count: 1
Lint/MissingSuper:
Exclude:
Expand All @@ -34,17 +20,12 @@ Metrics/AbcSize:
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# IgnoredMethods: refine
Metrics/BlockLength:
Max: 101
Max: 103

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 103

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 12
Max: 105

# Offense count: 1
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
Expand All @@ -53,26 +34,6 @@ Naming/MemoizedInstanceVariableName:
Exclude:
- 'test/test_helper.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: conservative, aggressive
Rails/ShortI18n:
Exclude:
- 'lib/page_title_helper.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/Encoding:
Exclude:
- 'page_title_helper.gemspec'

# Offense count: 1
# Cop supports --auto-correct.
Style/ExpandPathArguments:
Exclude:
- 'page_title_helper.gemspec'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
Expand All @@ -81,12 +42,6 @@ Style/FrozenStringLiteralComment:
Exclude:
- 'page_title_helper.gemspec'

# Offense count: 1
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Exclude:
- 'lib/page_title_helper.rb'

# Offense count: 1
Style/MixinUsage:
Exclude:
Expand All @@ -100,23 +55,16 @@ Style/ModuleFunction:
Exclude:
- 'lib/page_title_helper.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Exclude:
- 'page_title_helper.gemspec'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: RequireEnglish.
# SupportedStyles: use_perl_names, use_english_names
Style/SpecialGlobalVars:
EnforcedStyle: use_perl_names

# Offense count: 3
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 172
Max: 121
8 changes: 3 additions & 5 deletions lib/page_title_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def self.interpolate(pattern, *args)
end

def app(env)
env[:app] || I18n.translate('app.name', default: File.basename(Rails.root).humanize)
env[:app] || I18n.t('app.name', default: File.basename(Rails.root).humanize)
end

def title(env)
Expand Down Expand Up @@ -75,9 +75,7 @@ def page_title(options = nil)

# handle format aliases
format = options.delete(:format)
if PageTitleHelper.formats.include?(format)
format = PageTitleHelper.formats[format]
end
format = PageTitleHelper.formats[format] if PageTitleHelper.formats.include?(format)

# construct basic env to pass around
env = { title: title, app: options.delete(:app), options: options, view: self }
Expand All @@ -100,7 +98,7 @@ def page_title_from_translation(default)
keys << :"#{base}.title"
keys << default

I18n.translate(keys.shift, default: keys)
I18n.t(keys.shift, default: keys)
end
end

Expand Down
8 changes: 4 additions & 4 deletions page_title_helper.gemspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path('../lib', __FILE__)
$:.push File.expand_path('lib', __dir__)
require 'page_title_helper/version'

Gem::Specification.new do |s|
Expand All @@ -15,7 +14,8 @@ Gem::Specification.new do |s|
s.email = ['[email protected]']
s.homepage = 'https://github.com/lwe/page_title_helper'

s.files = %w{Gemfile LICENSE README.md CODE_OF_CONDUCT.md CHANGELOG.md Rakefile page_title_helper.gemspec} + Dir['**/*.{rb,yml}']
s.files = %w[Gemfile LICENSE README.md CODE_OF_CONDUCT.md CHANGELOG.md Rakefile
page_title_helper.gemspec] + Dir['**/*.{rb,yml}']
s.test_files = s.files.grep(%r{^(test|spec)/})
s.require_path = 'lib'

Expand All @@ -24,8 +24,8 @@ Gem::Specification.new do |s|
s.add_dependency 'rails', '>= 5.2.0', '< 6.2'

s.add_development_dependency 'rake', '~> 13.0.6'
s.add_development_dependency 'shoulda', '~> 4.0.0'
s.add_development_dependency 'rubocop', '~> 1.25.1'
s.add_development_dependency 'rubocop-rails', '~> 2.13.2'
s.add_development_dependency 'rubocop-rake', '~> 0.6.0'
s.add_development_dependency 'shoulda', '~> 4.0.0'
end
4 changes: 3 additions & 1 deletion test/page_title_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class PageTitleHelperTest < ActiveSupport::TestCase
PageTitleHelper.interpolates(:foobar_test) { |_env| 'foobar_test' }
PageTitleHelper.interpolates(:title_foobar) { |_env| 'title_foobar' }

assert_equal 'title_foobar / foobar_test / foobar / foobar_x', PageTitleHelper::Interpolations.interpolate(':title_foobar / :foobar_test / :foobar / :foobar_x', {})
assert_equal 'title_foobar / foobar_test / foobar / foobar_x',
PageTitleHelper::Interpolations.interpolate(':title_foobar / :foobar_test / :foobar / :foobar_x',
{})
end
end

Expand Down

0 comments on commit 80a1e8c

Please sign in to comment.