Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Adding Super Linter #7864

Merged
merged 11 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Autofix Ruby code with rubocop
  • Loading branch information
dshevtsov committed Sep 11, 2020
commit b89e9cbac7fa1fd9210655465f38230e66cd7977
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ source 'https://rubygems.org'

gem 'devdocs', git: 'https://github.com/magento-devdocs/devdocs-theme.git'
gem 'jekyll'
gem 'whatsup_github'
gem 'rake'
gem 'whatsup_github'

gem 'wdm', platform: :mswin

group :test do
gem 'html-proofer'
gem 'mdl'
gem 'launchy'
gem 'mdl'
end

group :optimization do
Expand All @@ -22,9 +22,9 @@ end

group :jekyll_plugins do
gem 'jekyll-algolia', '~> 1.0'
gem 'jekyll-optional-front-matter'
gem 'jekyll-redirect-from'
gem 'jekyll-relative-links'
gem 'jekyll-sitemap'
gem 'jekyll-titles-from-headings'
gem 'jekyll-relative-links'
gem 'jekyll-optional-front-matter'
end
8 changes: 4 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ desc 'Generate data for a news digest. Default timeframe is a week since today.
task :whatsnew do
date = ENV['since']
print 'Generating data for the weekly digest: $ '.magenta
if date.nil? or date.empty?
if date.nil? || date.empty?
sh 'bin/whatsup_github'
elsif date.is_a? String
sh 'bin/whatsup_github', 'since', ENV['since'].to_s
Expand All @@ -84,8 +84,8 @@ desc 'Generate index for Algolia'
task index: %w[init] do
puts 'Generating index for Algolia ...'
sh 'bin/jekyll',
'algolia',
'--config=_config.yml,_config.index.yml'
'algolia',
'--config=_config.yml,_config.index.yml'
end

desc 'Convert HTML text to kramdown in your terminal'
Expand All @@ -94,4 +94,4 @@ task :convert do
result = `bin/kramdown --input=html --output=kramdown`
puts 'Converted text:'.magenta
puts result.bold
end
end
8 changes: 5 additions & 3 deletions _plugins/algolia.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# frozen_string_literal: true

# Copyright © Magento, Inc. All rights reserved.
# See COPYING.txt for license details.

module Jekyll
module Algolia
module Hooks
def self.before_indexing_each(record, node, context)
def self.before_indexing_each(record, _node, _context)
# Do not index records larger than 20000 bytes
return nil if record.to_s.bytesize > 20000
return nil if record.to_s.bytesize > 20_000

record
end
end
Expand Down
8 changes: 5 additions & 3 deletions _plugins/liquid-tags/collapsible.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Copyright © Magento, Inc. All rights reserved.
# See COPYING.txt for license details.

Expand Down Expand Up @@ -30,7 +32,7 @@ def render(context)
<b class="collapsible-title">#{@title}</b>
<div class="collapsible-content">#{content}</div>
</div>
HTML
HTML
end
end

Expand Down Expand Up @@ -58,7 +60,7 @@ def render(context)
<h2 class="collapsible-title">#{@title}</h2>
<div class="collapsible-content">#{content}</div>
</div>
HTML
HTML
end
end

Expand All @@ -85,7 +87,7 @@ def render(context)
<h3 class="collapsible-title">#{@title}</h3>
<div class="collapsible-content">#{content}</div>
</div>
HTML
HTML
end
end
end
Expand Down
5 changes: 2 additions & 3 deletions _plugins/page-params/github-path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
# The parameter contains a file path relative to its repository.
#
Jekyll::Hooks.register :pages, :post_init do |page|

# Skip virtual pages like MRG topics
next if page.kind_of? Jekyll::PageWithoutAFile
next if page.is_a? Jekyll::PageWithoutAFile
# Process only files with 'md' and 'html' extensions
next unless File.extname(page.path).match?(/md|html/)
# Skip redirects
Expand All @@ -22,7 +21,7 @@
page.site.source,
File.dirname(page.path)
)

filename = File.basename page.path

# Change to the parent directory of the page and read full file path
Expand Down
4 changes: 2 additions & 2 deletions _plugins/page-params/last-modified-at.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
next if page.data['last_modified_at']

# Skip pages created by custom generators like 'mrg_pages'
next if page.kind_of? Jekyll::PageWithoutAFile
next if page.is_a? Jekyll::PageWithoutAFile

# Add site.source to the page path
file_path = File.join(page.site.source, page.path)

# Get real path of the page. If this is a symlink read it to get path of the real file with content.
real_filepath = File.realpath(file_path)

Expand Down
2 changes: 2 additions & 0 deletions _plugins/page-params/page-baseurl-generator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Copyright © Magento, Inc. All rights reserved.
# See COPYING.txt for license details.

Expand Down
2 changes: 2 additions & 0 deletions _plugins/page-params/page-canonical-url.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Copyright © Magento, Inc. All rights reserved.
# See COPYING.txt for license details.

Expand Down
4 changes: 2 additions & 2 deletions _plugins/page-params/page-versionless.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
filtering_pattern = '/guides/v'

next if page.url.start_with? filtering_pattern

page.data['versionless'] = true
end
end
1 change: 1 addition & 0 deletions _plugins/page-params/page-versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
urls_filtered_by_pattern =
pages.select do |site_page|
next if site_page.name == 'redirect.html'

site_page.url.start_with? filtering_pattern
end.map(&:url)

Expand Down
14 changes: 7 additions & 7 deletions bin/htmlproofer
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
# this file is here to facilitate running it.
#

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path("../bundle", __FILE__)
bundle_binstub = File.expand_path('bundle', __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
Expand All @@ -23,7 +23,7 @@ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this
end
end

require "rubygems"
require "bundler/setup"
require 'rubygems'
require 'bundler/setup'

load Gem.bin_path("html-proofer", "htmlproofer")
load Gem.bin_path('html-proofer', 'htmlproofer')
14 changes: 7 additions & 7 deletions bin/image_optim
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
# this file is here to facilitate running it.
#

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path("../bundle", __FILE__)
bundle_binstub = File.expand_path('bundle', __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
Expand All @@ -23,7 +23,7 @@ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this
end
end

require "rubygems"
require "bundler/setup"
require 'rubygems'
require 'bundler/setup'

load Gem.bin_path("image_optim", "image_optim")
load Gem.bin_path('image_optim', 'image_optim')
6 changes: 4 additions & 2 deletions bin/jekyll
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
Expand All @@ -7,8 +9,8 @@
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath)

require 'rubygems'
require 'bundler/setup'
Expand Down
14 changes: 7 additions & 7 deletions bin/kramdown
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
# this file is here to facilitate running it.
#

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path("../bundle", __FILE__)
bundle_binstub = File.expand_path('bundle', __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
Expand All @@ -23,7 +23,7 @@ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this
end
end

require "rubygems"
require "bundler/setup"
require 'rubygems'
require 'bundler/setup'

load Gem.bin_path("kramdown", "kramdown")
load Gem.bin_path('kramdown', 'kramdown')
14 changes: 7 additions & 7 deletions bin/mdl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
# this file is here to facilitate running it.
#

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path("../bundle", __FILE__)
bundle_binstub = File.expand_path('bundle', __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
Expand All @@ -23,7 +23,7 @@ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this
end
end

require "rubygems"
require "bundler/setup"
require 'rubygems'
require 'bundler/setup'

load Gem.bin_path("mdl", "mdl")
load Gem.bin_path('mdl', 'mdl')
14 changes: 7 additions & 7 deletions bin/whatsup_github
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
# this file is here to facilitate running it.
#

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path("../bundle", __FILE__)
bundle_binstub = File.expand_path('bundle', __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
Expand All @@ -23,7 +23,7 @@ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this
end
end

require "rubygems"
require "bundler/setup"
require 'rubygems'
require 'bundler/setup'

load Gem.bin_path("whatsup_github", "whatsup_github")
load Gem.bin_path('whatsup_github', 'whatsup_github')
4 changes: 1 addition & 3 deletions lib/double_slash_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ def run
@link = create_element(node)
line = node.line

if slash?
return add_issue('Remove double forward slashes from URLs', line: line)
end
return add_issue('Remove double forward slashes from URLs', line: line) if slash?
end
end
end
Expand Down
25 changes: 13 additions & 12 deletions rakelib/build.rake
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
# frozen_string_literal: true

# Copyright © Magento, Inc. All rights reserved.
# See COPYING.txt for license details.

namespace :build do

desc 'Build the site for production'
task prod: %w[init] do
print 'Building the site for production: $ '.magenta
sh 'bin/jekyll',
'build',
'--config=_config.yml,_config.prod.yml',
'--verbose',
'--profile',
'--trace'
'build',
'--config=_config.yml,_config.prod.yml',
'--verbose',
'--profile',
'--trace'
end

desc 'Build the site for staging'
task :stage do
print 'Building the site for staging: $ '.magenta
sh 'bin/jekyll',
'build',
"--baseurl=/#{ENV['BUILD_NUMBER']}",
'--config=_config.yml,_config.stage.yml',
'--verbose',
'--trace',
'--profile'
'build',
"--baseurl=/#{ENV['BUILD_NUMBER']}",
'--config=_config.yml,_config.stage.yml',
'--verbose',
'--trace',
'--profile'
end
end
Loading