1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00

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