Update rubocop + use enable-frozen-string-literal (#2354)

This commit is contained in:
Alexey Vasiliev 2020-08-16 22:08:50 +03:00 committed by GitHub
parent a03aed2d6d
commit 61915cdaab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
232 changed files with 597 additions and 124 deletions

View File

@ -1,6 +1,8 @@
require: rubocop-performance
require:
- rubocop-performance
AllCops:
NewCops: disable
TargetRubyVersion: 2.5
Include:
- "**/*.rb"
@ -11,11 +13,16 @@ AllCops:
- "vendor/**/*"
- "**/tmp/**/*"
- "middleman-cli/lib/middleman-cli/templates/**/*"
Style/FrozenStringLiteralComment:
Enabled: true
EnforcedStyle: always
Security/YAMLLoad:
Enabled: false
Style/GuardClause:
Enabled: false
Metrics/LineLength:
Layout/LineLength:
Enabled: false
Metrics/MethodLength:
Enabled: false
@ -39,13 +46,13 @@ Lint/AmbiguousBlockAssociation:
Enabled: false
Lint/UriEscapeUnescape:
Enabled: false
Lint/HandleExceptions:
Lint/SuppressedException:
Enabled: false
Lint/ShadowedException:
Enabled: false
Naming/FileName:
Enabled: false
Naming/UncommunicativeMethodParamName:
Naming/MethodParameterName:
Enabled: false
Naming/MemoizedInstanceVariableName:
Enabled: false
@ -57,9 +64,7 @@ Style/ClassAndModuleChildren:
Enabled: false
Style/MissingRespondToMissing:
Enabled: false
Style/MethodMissingSuper:
Enabled: false
Style/FrozenStringLiteralComment:
Lint/MissingSuper:
Enabled: false
Style/EvalWithLocation:
Enabled: false
@ -67,3 +72,5 @@ Style/ClassVars:
Enabled: false
Style/GlobalVars:
Enabled: false
Style/Proc:
Enabled: false

View File

@ -1,4 +1,5 @@
language: ruby
dist: xenial
cache: bundler
rvm:
- ruby-head
@ -7,11 +8,10 @@ rvm:
- 2.5
os:
- linux
matrix:
jobs:
fast_finish: true
allow_failures:
- rvm: ruby-head
env:
global:
- TEST=true
script: bundle exec rake test

View File

@ -38,8 +38,8 @@ gem 'mini_racer', '~> 0.2.4', platforms: :ruby
gem 'therubyrhino', '>= 2.0', platforms: :jruby
# Code Quality
gem 'rubocop', '~> 0.70.0', require: false
gem 'rubocop-performance', require: false
gem 'rubocop', '~> 0.89', require: false
gem 'rubocop-performance', '~> 1.7', require: false
gem 'simplecov', '~> 0.10', require: false
# Middleman itself

View File

@ -49,7 +49,7 @@ GEM
ffi (~> 1.9)
rspec-expectations (>= 2.99)
thor (>= 0.19, < 2.0)
ast (2.4.0)
ast (2.4.1)
backports (3.17.1)
binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
@ -109,7 +109,6 @@ GEM
i18n (0.9.5)
concurrent-ruby (~> 1.0)
interception (0.5)
jaro_winkler (1.5.4)
kramdown (2.3.0)
rexml
lazy_priority_queue (0.1.1)
@ -140,9 +139,9 @@ GEM
padrino-support (= 0.14.4)
tilt (>= 1.4.1, < 3)
padrino-support (0.14.4)
parallel (1.19.1)
parser (2.7.1.2)
ast (~> 2.4.0)
parallel (1.19.2)
parser (2.7.1.4)
ast (~> 2.4.1)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
@ -164,6 +163,7 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
redcarpet (3.5.0)
regexp_parser (1.7.1)
rexml (3.2.4)
rgl (0.5.6)
lazy_priority_queue (~> 0.1.0)
@ -181,15 +181,19 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
rubocop (0.70.0)
jaro_winkler (~> 1.5.1)
rubocop (0.89.1)
parallel (~> 1.10)
parser (>= 2.6)
parser (>= 2.7.1.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.3.0, < 1.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-performance (1.3.0)
rubocop (>= 0.68.0)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.3.0)
parser (>= 2.7.1.4)
rubocop-performance (1.7.1)
rubocop (>= 0.82.0)
ruby-progressbar (1.10.1)
ruby2_keywords (0.0.2)
rubydns (1.0.3)
@ -226,7 +230,7 @@ GEM
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.6.1)
unicode-display_width (1.7.0)
xpath (2.1.0)
nokogiri (~> 1.3)
yard (0.9.25)
@ -254,8 +258,8 @@ DEPENDENCIES
rake (~> 12.3)
redcarpet (>= 3.1)
rspec (~> 3.0)
rubocop (~> 0.70.0)
rubocop-performance
rubocop (~> 0.89)
rubocop-performance (~> 1.7)
rubydns (~> 1.0.1)
sassc (~> 2.0)
simplecov (~> 0.10)

View File

@ -44,8 +44,6 @@ end
desc 'Run tests for all middleman gems'
task :test do
Rake::Task['rubocop'].invoke
GEM_PATHS.each do |g|
Dir.chdir(File.join(ROOT, g).to_s) { sh "#{Gem.ruby} -S rake test" }
end
@ -63,4 +61,4 @@ desc 'Run RuboCop to check code consistency'
RuboCop::RakeTask.new(:rubocop)
desc 'Run tests for all middleman gems'
task default: :test
task default: %i[rubocop test]

View File

@ -1,3 +1,5 @@
RAKE_ROOT = __FILE__.freeze
GEM_NAME = 'middleman-cli'.freeze
# frozen_string_literal: true
RAKE_ROOT = __FILE__
GEM_NAME = 'middleman-cli'
require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')

View File

@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'middleman-core/profiling'
Middleman::Profiling.profiler = Middleman::Profiling::RubyProfProfiler.new if ARGV.include? '--profile'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
ENV['TEST'] = 'true'
require 'active_support/all'

View File

@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'rubydns'
require 'psych'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
set :layout, false
class MyFeature < Middleman::Extension

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Setup our load paths
libdir = __dir__
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'middleman-core/application'
# CLI Module
@ -126,7 +128,7 @@ module Middleman::Cli
puts 'Project built successfully.'
else
msg = 'There were errors during this build'
msg << ', re-run with `middleman build --verbose` to see the full exception.' unless options['verbose']
msg = "#{msg}, re-run with `middleman build --verbose` to see the full exception." unless options['verbose']
shell.say msg, :red
exit(1)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# CLI Module
module Middleman::Cli
# The CLI Config class

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# CLI Module
module Middleman::Cli
# The CLI Console class

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# CLI Module
module Middleman::Cli
# A thor task for creating new projects

View File

@ -1,10 +1,12 @@
# frozen_string_literal: true
# CLI Module
module Middleman::Cli
# A thor task for creating new projects
class Init < Thor::Group
include Thor::Actions
GIT_CMD = 'git'.freeze
GIT_CMD = 'git'
check_unknown_options!
@ -32,9 +34,11 @@ module Middleman::Cli
require 'tmpdir'
unless git_present?
msg = 'You need to install the git command line tool to initialize a new project. '
msg << "For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git"
say msg, :red
msg_array = [
'You need to install the git command line tool to initialize a new project. ',
"For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git"
]
say msg_array.join, :red
exit 1
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# CLI Module
module Middleman::Cli
# Server thor task

View File

@ -1,2 +1,4 @@
# frozen_string_literal: true
# Backwards compat
require 'middleman-cli'

View File

@ -1,3 +1,5 @@
RAKE_ROOT = __FILE__.freeze
# frozen_string_literal: true
RAKE_ROOT = __FILE__
GEM_NAME = ENV['NAME'] || 'middleman-core'
require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
ENV['TEST'] = 'true'
require 'active_support/all'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
Around('@preserve_mime_types') do |_scenario, block|
mime_types = ::Rack::Mime::MIME_TYPES.clone

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
activate :asset_hash
activate :relative_assets

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
configure :build do
# Minify JavaScript on build
activate :minify_javascript

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
activate :asset_hash,
prefix: 'myprefix-'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
activate :asset_hash,
rename_proc: lambda do |path, _basename, digest, extension, _options|
"#{path}#{digest}#{extension}"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
activate :asset_hash
activate :relative_assets

View File

@ -1 +1,3 @@
# frozen_string_literal: true
activate :asset_host, host: 'http://assets1.example.com'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
%w[
/auto-css.html
/auto-css

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
%w[
/auto-js.html
/auto-js

View File

@ -1 +1,3 @@
# frozen_string_literal: true
activate :directory_indexes

View File

@ -1 +1,3 @@
# frozen_string_literal: true
set :automatic_directory_matcher, '--'

View File

@ -1,2 +1,4 @@
# frozen_string_literal: true
data.store :static_array, ::YAML.load_file(File.expand_path('static_array.yml', File.dirname(__FILE__)))
data.store :static_hash, ::YAML.load_file(File.expand_path('static_hash.yml', File.dirname(__FILE__)))

View File

@ -1 +1,3 @@
# frozen_string_literal: true
set :layout, false

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'slim'
page '/capture_html_erb.html', layout: :capture_html

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
proxy '/fake.html', '/real.html', layout: false
ignore '/should_be_ignored.html'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
set :build_dir, '.build'
ignore '/should_be_ignored.html'

View File

@ -1 +1,3 @@
# frozen_string_literal: true
set :build_dir, '.build'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
proxy '/fake.html', '/real.html', layout: false
ignore '/should_be_ignored.html'

View File

@ -1 +1,3 @@
# frozen_string_literal: true
activate :directory_indexes

View File

@ -1 +1,3 @@
# frozen_string_literal: true
set :build_dir, 'sub/dir'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'slim'
page '/content_for_erb.html', layout: :content_for

View File

@ -1 +1,3 @@
# frozen_string_literal: true
set :erb, layout_engine: :str

View File

@ -1 +1,3 @@
# frozen_string_literal: true
set :source, 'src'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
data.pages.each do |p|
proxy p.from, p.to
end

View File

@ -1,2 +1,4 @@
# frozen_string_literal: true
files.watch :source, path: File.join(root, '..', 'external'),
destination_dir: 'my_dir'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
proxy '/fake.html', '/real.html', layout: false
proxy 'fake2.html', '/real.html', layout: false
proxy 'fake3.html', 'real.html', layout: false

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class LayoutDisabler < Middleman::Extension
def initialize(app, options_hash = {}, &block)
super

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
set :layout, false
class MyFeature < Middleman::Extension

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'lib/hello_helper'
helpers HelloHelper

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Derp
def three
'Three'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module FourHelpers
def four
'Four'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module OneHelper
def one
'One'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module YetAnotherThingy
def two
'Two'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module HelloHelper
def hello
'Hello World'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
activate :external_pipeline,
name: :failing,
command: 'mv does-not-exist tmp/file.js',

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
set :layout, false
class ExtensionA < ::Middleman::Extension

View File

@ -1 +1,3 @@
# frozen_string_literal: true
config[:frontmatter_delims][:yaml] << %w[\\--- \\---]

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
ignore '*.frontmatter'
# Reads neighbor for every file on every refresh.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Proxy ignored.html, which should ignore itself through a frontmatter
proxy 'proxied.html', 'ignored.html'
page 'override_layout.html', layout: :alternate

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Proxy ignored.html, which should ignore itself through a frontmatter
proxy 'proxied.html', 'ignored.html'
proxy 'proxied_with_frontmatter.html', 'ignored.html'

View File

@ -1 +1,3 @@
# frozen_string_literal: true
page '/index.html', layout: false

View File

@ -1 +1,3 @@
# frozen_string_literal: true
activate :gzip

View File

@ -1 +1,3 @@
# frozen_string_literal: true
set :encoding, 'ISO-8859-1'

View File

@ -1 +1,3 @@
# frozen_string_literal: true
activate :i18n

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
%i[en es].each do |locale|
proxy "/#{locale}/index.html", 'index.html', ignore: true, lang: locale
end

View File

@ -1 +1,3 @@
# frozen_string_literal: true
activate :i18n, mount_at_root: :en, langs: %i[en es]

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
import_file File.expand_path('static.html', root), '/static2.html'
import_path File.expand_path('bower_components/', root)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
activate :directory_indexes
page '/leave_me_alone.html', directory_index: false

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
page '/spaces in file.html', layout: false
config[:port] = 5555

View File

@ -1 +1,2 @@
# frozen_string_literal: true
# activate :minify_css

View File

@ -1 +1,3 @@
# frozen_string_literal: true
set :layout, :custom

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
set :layout, :custom
page '/', layout: :another

View File

@ -1 +1,3 @@
# frozen_string_literal: true
set :layout, :custom

View File

@ -1 +1,3 @@
# frozen_string_literal: true
set :markdown, smartypants: true

View File

@ -1 +1,3 @@
# frozen_string_literal: true
set :markdown, smartypants: true

View File

@ -1,2 +1,4 @@
# frozen_string_literal: true
ignore 'danger-zone/*'
ignore '*.textile'

View File

@ -1 +1,3 @@
# frozen_string_literal: true
activate :directory_indexes

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
activate :directory_indexes
# Proxy ignored.html, which should ignore itself through a frontmatter

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
activate :directory_indexes
proxy '/sub/fake.html', '/proxied.html', ignore: true

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
files.watch :data, path: File.join(root, 'data0'), priority: 100
files.watch :data, path: File.join(root, 'data1')
files.watch :data, path: File.join(root, 'data2')

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
files.watch :source, path: File.join(root, 'source0'), priority: 100
files.watch :source, path: File.join(root, 'source1')
files.watch :source, path: File.join(root, 'source2')

View File

@ -1,2 +1,4 @@
# frozen_string_literal: true
files.watch :source, path: File.join(root, 'external'),
destination_dir: 'external'

View File

@ -1,2 +1,4 @@
# frozen_string_literal: true
files.watch :source, path: File.join(root, 'source2'),
destination_dir: 'source2'

View File

@ -1 +1,3 @@
# frozen_string_literal: true
files.watch :source, path: File.join(root, 'external')

View File

@ -1 +1,3 @@
# frozen_string_literal: true
set :layout, false

View File

@ -1 +1,3 @@
# frozen_string_literal: true
set :layout, :inner

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
helpers do
def title
content_tag :h1 do

View File

@ -1,2 +1,4 @@
# frozen_string_literal: true
page '/sub1/page-classes.html', layout: false
page '/sub1/sub2/page-classes.html', layout: false

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
page '/path/*', layout: 'alt'
# Doesn't work, and shouldn't

View File

@ -1,7 +1,9 @@
# frozen_string_literal: true
%w[1 2 3].each do |n|
proxy "/#{n}.html", '/index.html', id: "page#{n}"
end
page '/overwrites/*', id: :"something-else"
config[:page_id_generator] = ->(path) { path + '-foo' }
config[:page_id_generator] = ->(path) { "#{path}-foo" }

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
%w[1 2 3].each do |n|
proxy "/#{n}.html", '/index.html', id: "page#{n}"
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
proxy '/fake.html', '/real.html', layout: false
proxy 'fake2.html', '/real.html', layout: false
proxy 'fake3.html', 'real.html', layout: false

View File

@ -1 +1,3 @@
# frozen_string_literal: true
redirect 'external.html', to: 'http://example.com'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
set :fonts_dir, 'fonts'
configure :build do

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
set :sass_assets_paths, [
File.join(root, 'assets', 'stylesheets'),
File.join(root, 'my-vendor', 'stylesheets')

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
proxy '/sub/fake.html', '/proxied.html', ignore: true
proxy '/sub/fake2.html', '/proxied.html', ignore: true

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ExtensionOne < ::Middleman::Extension
helpers do
def extension_two_was_activated

View File

@ -1 +1,3 @@
# frozen_string_literal: true
page '/admin/*', layout: :admin

View File

@ -1,2 +1,4 @@
# frozen_string_literal: true
activate :directory_indexes
page '/admin/*', layout: :admin

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Setup our load paths
libdir = __dir__
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)

Some files were not shown because too many files have changed in this diff Show More