Skip to content

Commit

Permalink
rubocop: Remove obsoleted settings
Browse files Browse the repository at this point in the history
  • Loading branch information
tkareine committed Feb 29, 2020
1 parent 9ed6f73 commit 8c7d9d2
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 49 deletions.
8 changes: 1 addition & 7 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ AllCops:
DisplayStyleGuide: true
TargetRubyVersion: 2.3
Layout/ExtraSpacing:
Enabled: false # does not work with trailing comments
AllowBeforeTrailingComments: true
Layout/HashAlignment:
EnforcedColonStyle: table
EnforcedHashRocketStyle: table
Expand Down Expand Up @@ -33,12 +33,8 @@ Style/ClassVars:
Enabled: false # it's ok when knowing it's limitations, easy to access from class instance scope
Style/CollectionMethods:
Enabled: true
Style/Copyright:
Enabled: false # we have copyright in the readme
Style/Documentation:
Enabled: false # we have documentation in the readme
Style/Encoding:
Enabled: false # we have some sources with non-ascii chars (in utf-8 encoding), we like stating encoding explicitly
Style/HashEachMethods:
Enabled: true
Style/HashTransformKeys:
Expand All @@ -49,5 +45,3 @@ Style/IfUnlessModifier:
Enabled: false # we like to use if/unless blocks for single-line expressions or statements that are long, avoiding making the line even longer with trailing if/unless modifier
Style/NumericPredicate:
EnforcedStyle: comparison
Style/PercentLiteralDelimiters:
Enabled: false # it's better to use `%w{}` syntax, because the braces are the same as in `%r{}`
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ end

RuboCop::RakeTask.new

task default: %i{rubocop test}
task default: %i[rubocop test]
1 change: 0 additions & 1 deletion benchmark/variable_template_bm.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# frozen_string_literal: true

require 'benchmark/ips'
Expand Down
4 changes: 2 additions & 2 deletions jekyll-minibundle.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ There are no other runtime dependencies besides the minification tool
(not even other gems).
TEXT

s.files = %w{
s.files = %w[
CHANGELOG.md
LICENSE.txt
README.md
Rakefile
jekyll-minibundle.gemspec
} + `git ls-files -- lib`.split("\n")
] + `git ls-files -- lib`.split("\n")

s.test_files = `git ls-files -- test`.split("\n")

Expand Down
4 changes: 2 additions & 2 deletions lib/jekyll/minibundle/asset_file_drop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ module Jekyll::Minibundle
class AssetFileDrop < ::Liquid::Drop
extend Forwardable

KEYS = %w{
KEYS = %w[
name
extname
basename
modified_time
path
collection
}.freeze
].freeze

def initialize(file)
@file = file
Expand Down
8 changes: 4 additions & 4 deletions lib/jekyll/minibundle/asset_tag_markup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ def self.make_markup(type, url, attributes)

case type
when :js
%{<script type="text/javascript" src="#{url_str}"#{attributes_str}></script>}
%(<script type="text/javascript" src="#{url_str}"#{attributes_str}></script>)
when :css
%{<link rel="stylesheet" href="#{url_str}"#{attributes_str}>}
%(<link rel="stylesheet" href="#{url_str}"#{attributes_str}>)
else
raise ArgumentError, "Unknown type for generating bundle markup: #{type}, #{url}"
end
Expand All @@ -24,9 +24,9 @@ def self.make_attributes(attributes)

def self.make_attribute(name, value)
if value.nil?
%{ #{name}}
%( #{name})
else
%{ #{name}="#{CGI.escape_html(value.to_s)}"}
%( #{name}="#{CGI.escape_html(value.to_s)}")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll/minibundle/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self.minifier_command(site, type)
end

def self.development?(site)
mode = ENV['JEKYLL_MINIBUNDLE_MODE'] || Environment.find_site_config(site, %w{minibundle mode}, String)
mode = ENV['JEKYLL_MINIBUNDLE_MODE'] || Environment.find_site_config(site, %w[minibundle mode], String)
mode == 'development'
end

Expand Down
8 changes: 4 additions & 4 deletions test/integration/minibundle_development_mode_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module Jekyll::Minibundle::Test
class MinibundleDevelopmentModeTest < TestCase
include FixtureConfig

CSS_ASSET_DESTINATION_PATHS = %w{reset common}.map { |f| File.join(CSS_BUNDLE_DESTINATION_PATH, "#{f}.css") }
JS_ASSET_DESTINATION_PATHS = %w{dependency app}.map { |f| File.join(JS_BUNDLE_DESTINATION_PATH, "#{f}.js") }
CSS_ASSET_DESTINATION_PATHS = %w[reset common].map { |f| File.join(CSS_BUNDLE_DESTINATION_PATH, "#{f}.css") }
JS_ASSET_DESTINATION_PATHS = %w[dependency app].map { |f| File.join(JS_BUNDLE_DESTINATION_PATH, "#{f}.js") }

def test_css_assets_have_tags_in_configured_order
with_precompiled_site(:development) do
Expand All @@ -25,7 +25,7 @@ def test_js_assets_have_tags_in_configured_order
def test_css_assets_have_configured_attributes
with_precompiled_site(:development) do
elements = find_css_elements_from_index.map { |el| [el['id'], el['media']] }.uniq
assert_equal([%w{my-styles projection}], elements)
assert_equal([%w[my-styles projection]], elements)
end
end

Expand Down Expand Up @@ -502,7 +502,7 @@ def test_allows_root_dir_as_source_dir

generate_site(:development)

assert_equal(%w{dependency app}.map { |p| File.join(JS_BUNDLE_DESTINATION_PATH, '_assets/scripts', "#{p}.js") }, find_js_paths_from_index)
assert_equal(%w[dependency app].map { |p| File.join(JS_BUNDLE_DESTINATION_PATH, '_assets/scripts', "#{p}.js") }, find_js_paths_from_index)
assert(File.file?(destination_path(File.join(JS_BUNDLE_DESTINATION_PATH, '_assets/scripts/dependency.js'))))
assert(File.file?(destination_path(File.join(JS_BUNDLE_DESTINATION_PATH, '_assets/scripts/app.js'))))
end
Expand Down
8 changes: 4 additions & 4 deletions test/integration/minibundle_production_mode_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ def test_inserts_semicolons_between_js_assets

def test_minifies_css_asset_bundle
with_precompiled_site(:production) do
source_contents_size = source_assets_size(CSS_BUNDLE_SOURCE_DIR, %w{reset common}, 'css')
source_contents_size = source_assets_size(CSS_BUNDLE_SOURCE_DIR, %w[reset common], 'css')
destination_contents_size = File.read(destination_path(CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH)).size
assert_operator(destination_contents_size, :<, source_contents_size)
end
end

def test_minifies_js_asset_bundle
with_precompiled_site(:production) do
source_contents_size = source_assets_size(JS_BUNDLE_SOURCE_DIR, %w{dependency app}, 'js')
source_contents_size = source_assets_size(JS_BUNDLE_SOURCE_DIR, %w[dependency app], 'js')
destination_contents_size = File.read(destination_path(JS_BUNDLE_DESTINATION_FINGERPRINT_PATH)).size
assert_operator(destination_contents_size, :<, source_contents_size)
end
Expand Down Expand Up @@ -757,8 +757,8 @@ def test_escapes_destination_path_url_and_attributes_in_generated_html_element

generate_site(:production)

assert(File.file?(destination_path(%{dst">-#{JS_BUNDLE_FINGERPRINT}.js})))
assert_equal(%{dst">-#{JS_BUNDLE_FINGERPRINT}.js}, find_js_path_from_index)
assert(File.file?(destination_path(%(dst">-#{JS_BUNDLE_FINGERPRINT}.js))))
assert_equal(%(dst">-#{JS_BUNDLE_FINGERPRINT}.js), find_js_path_from_index)
assert_equal('"/><br>', find_js_element_from_index['test'])
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/integration/static_files_as_asset_sources_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_asset_and_static_files_with_same_destination_paths_can_coexist
end
end

%i{development production}.each do |env|
%i[development production].each do |env|
define_method :"test_ministamp_allows_using_static_file_as_asset_source_in_#{env}_mode" do
with_site_dir do
contents = 'h2 {}'
Expand Down
4 changes: 2 additions & 2 deletions test/support/static_file_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Jekyll::Minibundle::Test
module StaticFileConfig
STATIC_FILE_PROPERTIES = %i{
STATIC_FILE_PROPERTIES = %i[
basename
data
defaults
Expand All @@ -18,6 +18,6 @@ module StaticFileConfig
type
url
write?
}.freeze
].freeze
end
end
8 changes: 4 additions & 4 deletions test/unit/asset_file_registry_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_register_returns_different_development_file_collections_for_bundle_conf
end

[
{description: 'assets', config_diff: {'assets' => %w{b1 b2}}},
{description: 'assets', config_diff: {'assets' => %w[b1 b2]}},
{description: 'source_directory', config_diff: {'source_dir' => '_assets/src2'}}
].each do |spec|
define_method :"test_raise_exception_if_registering_bundle_file_with_same_destination_path_but_with_different_#{spec.fetch(:description)}" do
Expand All @@ -98,7 +98,7 @@ def test_register_returns_different_development_file_collections_for_bundle_conf
end

[
{description: 'assets', config_diff: {'assets' => %w{b1 b2}}},
{description: 'assets', config_diff: {'assets' => %w[b1 b2]}},
{description: 'source_directory', config_diff: {'source_dir' => '_assets/src2'}}
].each do |spec|
define_method :"test_raise_exception_if_registering_development_file_collection_with_same_destination_path_but_with_different_#{spec.fetch(:description)}" do
Expand Down Expand Up @@ -144,7 +144,7 @@ def test_register_returns_different_development_file_collections_for_bundle_conf

define_method :"test_raise_exception_if_registering_#{spec.fetch(:description)}s_with_different_source_and_same_destination_paths" do
with_fake_site do |site|
source_paths = %w{src1.css src2.css}.map do |file|
source_paths = %w[src1.css src2.css].map do |file|
File.join(CSS_BUNDLE_SOURCE_DIR, file)
end
source_paths.each { |path| FileUtils.touch(path) }
Expand Down Expand Up @@ -229,7 +229,7 @@ def bundle_config
{
'type' => :js,
'source_dir' => JS_BUNDLE_SOURCE_DIR,
'assets' => %w{dependency app},
'assets' => %w[dependency app],
'destination_path' => JS_BUNDLE_DESTINATION_PATH,
'minifier_cmd' => 'unused_minifier_cmd'
}
Expand Down
10 changes: 5 additions & 5 deletions test/unit/asset_tag_markup_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ module Jekyll::Minibundle::Test
class AssetTagMarkupTest < TestCase
def test_escape_url
actual = AssetTagMarkup.make_markup(:css, 'https://example.com/path?a=this+"thing"&b=<br>', {})
expected = %{<link rel="stylesheet" href="https://example.com/path?a=this+&quot;thing&quot;&amp;b=&lt;br&gt;">}
expected = %(<link rel="stylesheet" href="https://example.com/path?a=this+&quot;thing&quot;&amp;b=&lt;br&gt;">)
assert_equal(expected, actual)
end

def test_escape_attribute_value
attributes = {media: 'screen, projection', extra: '">attack<br'}
actual = AssetTagMarkup.make_markup(:css, '/asset.css', attributes)
expected = %{<link rel="stylesheet" href="/asset.css" media="screen, projection" extra="&quot;&gt;attack&lt;br">}
expected = %(<link rel="stylesheet" href="/asset.css" media="screen, projection" extra="&quot;&gt;attack&lt;br">)
assert_equal(expected, actual)
end

def test_output_just_attribute_name_for_nil_value
actual = AssetTagMarkup.make_markup(:css, '/asset.css', async: nil)
expected = %{<link rel="stylesheet" href="/asset.css" async>}
expected = %(<link rel="stylesheet" href="/asset.css" async>)
assert_equal(expected, actual)
end

def test_convert_attribute_value_to_string
actual = AssetTagMarkup.make_markup(:css, '/asset.css', boolean: false)
expected = %{<link rel="stylesheet" href="/asset.css" boolean="false">}
expected = %(<link rel="stylesheet" href="/asset.css" boolean="false">)
assert_equal(expected, actual)
end

def test_output_empty_attribute_value
actual = AssetTagMarkup.make_markup(:css, '/asset.css', empty: '')
expected = %{<link rel="stylesheet" href="/asset.css" empty="">}
expected = %(<link rel="stylesheet" href="/asset.css" empty="">)
assert_equal(expected, actual)
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/bundle_file_properties_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def bundle_config(minifier_cmd)
{
'type' => :js,
'source_dir' => JS_BUNDLE_SOURCE_DIR,
'assets' => %w{dependency app},
'assets' => %w[dependency app],
'destination_path' => JS_BUNDLE_DESTINATION_PATH,
'minifier_cmd' => minifier_cmd
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/bundle_file_writing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_raise_error_if_source_directory_does_not_exist
def test_raise_error_if_asset_source_file_does_not_exist
err = assert_raises(ArgumentError) do
with_fake_site do |site|
make_bundle_file(site, 'assets' => %w{no-such})
make_bundle_file(site, 'assets' => %w[no-such])
end
end
assert_match(%r{\ABundle asset source file does not exist: .+/#{Regexp.escape(JS_BUNDLE_SOURCE_DIR)}/no-such.js\z}, err.to_s)
Expand Down Expand Up @@ -141,7 +141,7 @@ def make_bundle_file(site, config = {})
bundle_config = {
'type' => :js,
'source_dir' => JS_BUNDLE_SOURCE_DIR,
'assets' => %w{dependency app},
'assets' => %w[dependency app],
'destination_path' => JS_BUNDLE_DESTINATION_PATH,
'minifier_cmd' => minifier_cmd_to_remove_comments_and_count
}
Expand Down
6 changes: 3 additions & 3 deletions test/unit/environment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
module Jekyll::Minibundle::Test
class EnvironmentTest < TestCase
def test_find_site_config_returns_value_when_found
assert_equal(1, Environment.find_site_config(make_site(top: {leaf: 1}), %i{top leaf}, Integer))
assert_equal(1, Environment.find_site_config(make_site(top: {leaf: 1}), %i[top leaf], Integer))
end

def test_find_site_config_returns_nil_when_not_found
assert_nil(Environment.find_site_config(make_site, %i{top leaf}, Integer))
assert_nil(Environment.find_site_config(make_site, %i[top leaf], Integer))
end

def test_find_site_config_raises_exception_if_found_value_is_of_unexpected_type
err = assert_raises(RuntimeError) do
Environment.find_site_config(make_site(top: {leaf: '1'}), %i{top leaf}, Integer)
Environment.find_site_config(make_site(top: {leaf: '1'}), %i[top leaf], Integer)
end
assert_equal('Invalid site configuration for key top.leaf; expecting type Integer', err.to_s)
end
Expand Down
6 changes: 3 additions & 3 deletions test/unit/jekyll_static_file_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

module Jekyll::Minibundle::Test
class JekyllStaticFileAPITest < TestCase
IGNORED_STATIC_FILE_METHODS = %i{cleaned_relative_path}.freeze
IGNORED_STATIC_FILE_METHODS = %i[cleaned_relative_path].freeze

include StaticFileConfig

Expand Down Expand Up @@ -46,7 +46,7 @@ def test_bundle_file_properties_has_similar_return_types_to_static_file_properti

return_type_diff = diff_non_nil_response_types_of_static_file_properties(
make_static_file(site, 'static.txt'),
make_bundle_file(site, %w{dependency app})
make_bundle_file(site, %w[dependency app])
)

assert_empty(return_type_diff)
Expand Down Expand Up @@ -86,7 +86,7 @@ def test_bundle_file_has_same_to_liquid_hash_keys_as_static_file
FileUtils.touch('app.js')

expected_keys = make_static_file(site, 'static.txt').to_liquid.keys.sort
actual_keys = make_bundle_file(site, %w{dependency app}).to_liquid.keys.sort
actual_keys = make_bundle_file(site, %w[dependency app]).to_liquid.keys.sort

assert_equal(expected_keys, actual_keys)
end
Expand Down
2 changes: 1 addition & 1 deletion test/unit/mini_bundle_block_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_raise_exception_if_unsupported_block_contents_type
{% endminibundle %}
LIQUID

expected_output = %{<link rel="stylesheet" href="#{spec.fetch(:expected_asset_url)}">\n}
expected_output = %(<link rel="stylesheet" href="#{spec.fetch(:expected_asset_url)}">\n)

assert_equal(expected_output, actual_output)
end
Expand Down
1 change: 0 additions & 1 deletion test/unit/variable_template_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# frozen_string_literal: true

require 'support/test_case'
Expand Down

0 comments on commit 8c7d9d2

Please sign in to comment.