Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
fix rubocop violations (#1102)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsteves authored Mar 5, 2021
1 parent efcce4a commit b9cb34e
Show file tree
Hide file tree
Showing 326 changed files with 3,766 additions and 3,763 deletions.
24 changes: 12 additions & 12 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ source "https://rubygems.org"
# They are all for CI and tests
# `dev` uses no gems
group :development, :test do
gem 'rake'
gem 'pry-byebug'
gem 'byebug'
gem 'rubocop-shopify', require: false
gem 'rubocop-minitest', require: false
gem "rake"
gem "pry-byebug"
gem "byebug"
gem "rubocop-shopify", require: false
gem "rubocop-minitest", require: false
end

group :test do
gem 'mocha', require: false
gem 'minitest', '>= 5.0.0', require: false
gem 'minitest-reporters', require: false
gem 'minitest-fail-fast', require: false
gem 'fakefs', '>= 1.0', require: false
gem 'webmock', require: false
gem 'timecop', require: false
gem "mocha", require: false
gem "minitest", ">= 5.0.0", require: false
gem "minitest-reporters", require: false
gem "minitest-fail-fast", require: false
gem "fakefs", ">= 1.0", require: false
gem "webmock", require: false
gem "timecop", require: false
end
60 changes: 30 additions & 30 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require_relative 'bin/load_shopify'
require 'rake/testtask'
require 'rubocop/rake_task'
require 'bundler/gem_tasks'
require_relative "bin/load_shopify"
require "rake/testtask"
require "rubocop/rake_task"
require "bundler/gem_tasks"

Rake::TestTask.new do |t|
t.libs += %w(test)
t.test_files = FileList['test/**/*_test.rb']
t.test_files = FileList["test/**/*_test.rb"]
t.verbose = false
t.warning = false
end
Expand All @@ -16,50 +16,50 @@ task(default: [:test, :rubocop])

desc("Start up irb with cli loaded")
task :console do
exec('irb', '-r', './bin/load_shopify.rb', '-r', 'byebug')
exec("irb", "-r", "./bin/load_shopify.rb", "-r", "byebug")
end

namespace :rdoc do
repo = 'https://github.com/Shopify/shopify-app-cli.wiki.git'
intermediate = 'markdown_intermediate'
repo = "https://github.com/Shopify/shopify-app-cli.wiki.git"
intermediate = "markdown_intermediate"
file_to_doc = [
'lib/shopify-cli/admin_api.rb',
'lib/shopify-cli/context.rb',
'lib/shopify-cli/db.rb',
'lib/shopify-cli/git.rb',
'lib/shopify-cli/heroku.rb',
'lib/shopify-cli/js_deps.rb',
'lib/shopify-cli/method_object.rb',
'lib/shopify-cli/partners_api.rb',
'lib/shopify-cli/process_supervision.rb',
'lib/shopify-cli/project.rb',
'lib/shopify-cli/result.rb',
'lib/shopify-cli/tunnel.rb',
"lib/shopify-cli/admin_api.rb",
"lib/shopify-cli/context.rb",
"lib/shopify-cli/db.rb",
"lib/shopify-cli/git.rb",
"lib/shopify-cli/heroku.rb",
"lib/shopify-cli/js_deps.rb",
"lib/shopify-cli/method_object.rb",
"lib/shopify-cli/partners_api.rb",
"lib/shopify-cli/process_supervision.rb",
"lib/shopify-cli/project.rb",
"lib/shopify-cli/result.rb",
"lib/shopify-cli/tunnel.rb",
]

task all: [:markdown, :wiki, :cleanup]

desc("Generate markdown files from rdoc comments")
task :markdown do
require 'rdoc/rdoc'
require 'docgen/markdown'
require "rdoc/rdoc"
require "docgen/markdown"
options = RDoc::Options.new
options.setup_generator('markdown')
options.setup_generator("markdown")
options.op_dir = intermediate
options.files = file_to_doc
RDoc::RDoc.new.document(options)
end

desc("Copy markdown documentation to the wiki and commit them")
task :wiki do
require 'tmpdir'
require "tmpdir"
Dir.mktmpdir do |temp_dir|
system("git clone --depth=1 #{repo} #{temp_dir}")
FileUtils.cp(Dir[File.join(intermediate, '*.md')], temp_dir)
FileUtils.cp(Dir[File.join(intermediate, "*.md")], temp_dir)
Dir.chdir(temp_dir) do
system('git add --all')
system("git add --all")
system('git commit -am "auto doc update"')
system('git push')
system("git push")
end
end
end
Expand All @@ -71,10 +71,10 @@ namespace :rdoc do
end

desc("Generate markdown documentation and update the wiki")
task(rdoc: 'rdoc:all')
task(rdoc: "rdoc:all")

namespace :package do
require 'shopify-cli/packager'
require "shopify-cli/packager"

task all: [:debian, :rpm, :homebrew]

Expand All @@ -95,4 +95,4 @@ namespace :package do
end

desc("Builds all distribution packages of the CLI")
task(package: 'package:all')
task(package: "package:all")
12 changes: 6 additions & 6 deletions bin/load_shopify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
lib_path = File.expand_path("../../lib", __FILE__)
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)

ENV['SHELLPID'] ||= Process.ppid.to_s
ENV['USER_PWD'] ||= Dir.pwd
ENV["SHELLPID"] ||= Process.ppid.to_s
ENV["USER_PWD"] ||= Dir.pwd

# Prune non-absolute paths from PATH to prevent non-deterministic behavior
# i.e. If user has "." or "./bin" in their PATH
# Note that this logic is duplicated in lib/shopify.rb
ENV['PATH'] = ENV['PATH'].split(File::PATH_SEPARATOR).select do |p|
p.start_with?('/', '~', /[A-Z]:\\/)
ENV["PATH"] = ENV["PATH"].split(File::PATH_SEPARATOR).select do |p|
p.start_with?("/", "~", /[A-Z]:\\/)
end.join(File::PATH_SEPARATOR)

$original_env = ENV.to_hash

require 'shopify_cli'
require "shopify_cli"

if ENV['PRINT_LOADED_FEATURES']
if ENV["PRINT_LOADED_FEATURES"]
puts $LOADED_FEATURES
end
4 changes: 2 additions & 2 deletions bin/shopify
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Kernel
raise if name == "#{RUBY_VERSION[/\d+\.\d+/]}/psych.so"
STDERR.puts "[Note] You cannot use gems with Shopify App CLI."
STDERR.puts "[LoadError] #{e.message}"
if ENV['DEBUG']
if ENV["DEBUG"]
STDERR.puts e.backtrace
STDERR.puts "\n"
end
Expand All @@ -27,7 +27,7 @@ module Kernel
end
end

require_relative './load_shopify'
require_relative "./load_shopify"

exit(ShopifyCli::ErrorHandler.call do
ShopifyCli::Core::EntryPoint.call(ARGV.dup)
Expand Down
14 changes: 7 additions & 7 deletions ext/shopify-cli/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'rbconfig'
require 'fileutils'
require "rbconfig"
require "fileutils"

gem = File.expand_path('../../../', __FILE__)
exe = File.join(gem, 'bin', 'shopify')
gem = File.expand_path("../../../", __FILE__)
exe = File.join(gem, "bin", "shopify")

if RUBY_PLATFORM.match(/mingw32/)
bat_path = File.dirname(RbConfig.ruby)
Expand All @@ -22,8 +22,8 @@
\t echo "#{script_content}">> "#{bat}"
MAKEFILE
else
script = exe + '.sh'
symlink = '/usr/local/bin/shopify'
script = exe + ".sh"
symlink = "/usr/local/bin/shopify"

script_content = <<~SCRIPT
#!/usr/bin/env bash
Expand All @@ -44,4 +44,4 @@
MAKEFILE
end

File.write('Makefile', makefile_content)
File.write("Makefile", makefile_content)
22 changes: 11 additions & 11 deletions lib/docgen/markdown.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'rdoc/rdoc'
require 'erb'
require "rdoc/rdoc"
require "erb"

module RDoc
module Generator
Expand All @@ -26,13 +26,13 @@ def generate
private

def render(data)
class_template_path = File.join(File.dirname(__FILE__), 'class_template.md.erb')
class_renderer = ERB.new(File.read(class_template_path), nil, '-')
class_template_path = File.join(File.dirname(__FILE__), "class_template.md.erb")
class_renderer = ERB.new(File.read(class_template_path), nil, "-")
data.each do |cls|
File.write("#{cls.filename}.md", class_renderer.result(cls.instance_eval { binding }))
end
index_template_path = File.join(File.dirname(__FILE__), 'index_template.md.erb')
index_renderer = ERB.new(File.read(index_template_path), nil, '-')
index_template_path = File.join(File.dirname(__FILE__), "index_template.md.erb")
index_renderer = ERB.new(File.read(index_template_path), nil, "-")
File.write("Core-APIs.md", index_renderer.result(OpenStruct.new(classes: data).instance_eval { binding }))
end

Expand All @@ -46,8 +46,8 @@ def build_classes
kind: kind,
comment: @converter.convert(klass.comment.parse),
constants: build_members(klass.constants),
class_methods: build_members(klass.method_list.select { |m| m.type == 'class' }),
instance_methods: build_members(klass.method_list.select { |m| m.type == 'instance' }),
class_methods: build_members(klass.method_list.select { |m| m.type == "class" }),
instance_methods: build_members(klass.method_list.select { |m| m.type == "instance" }),
attributes: build_members(klass.attributes),
extended: build_members(klass.extends),
included: build_members(klass.includes),
Expand All @@ -68,7 +68,7 @@ def build_members(member_list)
ClassMember.new(
title: m.name,
comment: @converter.convert(m.comment.parse),
signature: m.respond_to?(:arglists) ? m.arglists : '',
signature: m.respond_to?(:arglists) ? m.arglists : "",
source_code: source(m),
)
end
Expand All @@ -77,7 +77,7 @@ def build_members(member_list)
# Just extracts sourcecode from html formatting/highlighting into a text
# blob so that markdown can format it with a codeblock
def source(m)
return '' unless m.respond_to?(:token_stream)
return "" unless m.respond_to?(:token_stream)
# each line, get the text
src = (m.token_stream || []).map do |t|
next unless t
Expand All @@ -93,7 +93,7 @@ def source(m)
indent = n if n < indent
break if n == 0
end
src.gsub!(/^#{' ' * indent}/, '') if indent > 0
src.gsub!(/^#{' ' * indent}/, "") if indent > 0
src
end
end
Expand Down
Loading

0 comments on commit b9cb34e

Please sign in to comment.