Skip to content

Commit

Permalink
Update style based on new Shopify Rules:
Browse files Browse the repository at this point in the history
- For the context on why we decided to add parenthesis around all
  method call, you can read about it here https://medium.com/@gmalette/revoking-the-privilege-b2af90a84d84
  • Loading branch information
Edouard-chin committed Dec 5, 2018
1 parent f1d6ac5 commit a386aa8
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 24 deletions.
24 changes: 21 additions & 3 deletions .rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml
@@ -1,9 +1,8 @@
# Recommended rubocop version: ~> 0.56.0

AllCops:
Exclude:
- 'db/schema.rb'
DisabledByDefault: true
StyleGuideBaseURL: https://shopify.github.io/ruby-style-guide/

Layout/AccessModifierIndentation:
EnforcedStyle: indent
Expand Down Expand Up @@ -102,7 +101,7 @@ Style/ClassCheck:
- kind_of?

Style/CommandLiteral:
EnforcedStyle: backticks
EnforcedStyle: percent_x
SupportedStyles:
- backticks
- percent_x
Expand Down Expand Up @@ -259,6 +258,19 @@ Style/Next:
Style/NonNilCheck:
IncludeSemanticChanges: false

Style/MethodCallWithArgsParentheses:
Enabled: true
IgnoreMacros: true
IgnoredMethods:
- require
- require_relative
- require_dependency
- yield
- raise
- puts
Exclude:
- Gemfile

Style/MethodDefParentheses:
EnforcedStyle: require_parentheses
SupportedStyles:
Expand Down Expand Up @@ -1110,6 +1122,9 @@ Performance/RedundantMatch:
Performance/RedundantSortBy:
Enabled: true

Performance/RegexpMatch:
Enabled: true

Performance/ReverseEach:
Enabled: true

Expand All @@ -1136,6 +1151,9 @@ Rails/HttpPositionalArguments:
- spec/**/*
- test/**/*

Rails/InverseOf:
Enabled: true

Rails/OutputSafety:
Enabled: true

Expand Down
7 changes: 6 additions & 1 deletion .rubocop.yml
Expand Up @@ -2,4 +2,9 @@ inherit_from:
- https://shopify.github.io/ruby-style-guide/rubocop.yml

AllCops:
TargetRubyVersion: 2.3
TargetRubyVersion: 2.5

Style/MethodCallWithArgsParentheses:
Exclude:
- Gemfile
- gemfiles/*
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -10,4 +10,4 @@ Rake::TestTask.new(:test) do |t|
t.test_files = FileList["test/**/*_test.rb"]
end

task default: :test
task(default: :test)
10 changes: 5 additions & 5 deletions deprecation_toolkit.gemspec
Expand Up @@ -20,14 +20,14 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = '>= 2.3'

spec.files = `git ls-files -z`.split("\x0").reject do |f|
spec.files = %x(git ls-files -z).split("\x0").reject do |f|
f.match(%r{^(test)/})
end
spec.require_paths = %w(lib)

spec.add_runtime_dependency 'activesupport', '>= 4.2'
spec.add_runtime_dependency('activesupport', '>= 4.2')

spec.add_development_dependency "bundler", "~> 1.16"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "minitest", "~> 5.0"
spec.add_development_dependency("bundler", "~> 1.16")
spec.add_development_dependency("rake", "~> 10.0")
spec.add_development_dependency("minitest", "~> 5.0")
end
2 changes: 1 addition & 1 deletion lib/deprecation_toolkit.rb
Expand Up @@ -25,7 +25,7 @@ def self.attach_subscriber
return if DeprecationSubscriber.already_attached?

Configuration.attach_to.each do |gem_name|
DeprecationSubscriber.attach_to gem_name
DeprecationSubscriber.attach_to(gem_name)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/minitest/deprecation_toolkit_plugin.rb
Expand Up @@ -4,7 +4,7 @@ module Minitest
extend self

def plugin_deprecation_toolkit_options(opts, options)
opts.on "-r", "--record-deprecations", "Record deprecations" do
opts.on("-r", "--record-deprecations", "Record deprecations") do
options[:record_deprecations] = true
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/deprecation_toolkit/behaviors/raise_test.rb
Expand Up @@ -71,7 +71,7 @@ def deprecation_callee

old_allowed_deprecations = Configuration.allowed_deprecations
Configuration.allowed_deprecations = [
->(_, stack) { stack.first.to_s =~ /my_file\.rb/ }
->(_, stack) { stack.first.to_s =~ /my_file\.rb/ },
]

begin
Expand All @@ -86,7 +86,7 @@ def trigger_deprecation_toolkit_behavior
super
flunk if defined?(@expected_exception)
rescue DeprecationIntroduced, DeprecationRemoved, DeprecationMismatch => e
assert_equal @expected_exception, e.class
assert_equal(@expected_exception, e.class)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/deprecation_toolkit/behaviors/record_test.rb
Expand Up @@ -64,7 +64,7 @@ def assert_deprecations_recorded(*deprecation_triggered)
recorded = YAML.load_file("#{@deprecation_path}/deprecation_toolkit/behaviors/record_test.yml").fetch(name)
triggered = deprecation_triggered.map { |msg| "DEPRECATION WARNING: #{msg}" }

assert_equal recorded, triggered
assert_equal(recorded, triggered)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/deprecation_toolkit/warning_test.rb
Expand Up @@ -26,7 +26,7 @@ class WarningTest < ActiveSupport::TestCase
Configuration.warnings_treated_as_deprecation = [/#example is deprecated/]

assert_raises Behaviors::DeprecationIntroduced do
Kernel.warn '#example is deprecated'
Kernel.warn('#example is deprecated')

trigger_deprecation_toolkit_behavior
end
Expand Down
12 changes: 5 additions & 7 deletions test/minitest/deprecation_toolkit_plugin_test.rb
Expand Up @@ -16,14 +16,12 @@ class DeprecationToolkitPluginTest < ActiveSupport::TestCase
end

test ".plugin_deprecation_toolkit_init set the behavior to `Record` when `record_deprecations` options is true" do
begin
previous_behavior = DeprecationToolkit::Configuration.behavior
Minitest.plugin_deprecation_toolkit_init(record_deprecations: true)
previous_behavior = DeprecationToolkit::Configuration.behavior
Minitest.plugin_deprecation_toolkit_init(record_deprecations: true)

assert_equal DeprecationToolkit::Behaviors::Record, DeprecationToolkit::Configuration.behavior
ensure
DeprecationToolkit::Configuration.behavior = previous_behavior
end
assert_equal(DeprecationToolkit::Behaviors::Record, DeprecationToolkit::Configuration.behavior)
ensure
DeprecationToolkit::Configuration.behavior = previous_behavior
end

test ".plugin_deprecation_toolkit_init add `notify` behavior to the deprecations behavior list" do
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
require "deprecation_toolkit"

require "minitest/autorun"
Expand Down

0 comments on commit a386aa8

Please sign in to comment.