Skip to content

Commit

Permalink
Add parentheses for all method calls (#11474)
Browse files Browse the repository at this point in the history
* Add parentheses for all method calls

Using rubocop

* Fix code style

* After merge updates

* Fix tests
  • Loading branch information
KrauseFx committed Jan 9, 2018
1 parent c012152 commit 1a79353
Show file tree
Hide file tree
Showing 449 changed files with 2,412 additions and 2,391 deletions.
21 changes: 21 additions & 0 deletions .rubocop.yml
Expand Up @@ -278,3 +278,24 @@ Style/IfInsideElse:
# Sometimes we just want to 'collect'
Style/CollectionMethods:
Enabled: false

# ( ) for method calls
Style/MethodCallWithArgsParentheses:
Enabled: true
IgnoredMethods:
- 'require'
- 'require_relative'
- 'gem'
- 'program'
- 'command'
- 'raise'
- 'attr_accessor'
- 'attr_reader'
- 'lane'
# rspec tests code below
- 'to'
- 'describe'
- 'it'
- 'context'
- 'before'
- 'after'
2 changes: 1 addition & 1 deletion Dangerfile
Expand Up @@ -29,5 +29,5 @@ if File.exist?(file_path)
junit.headers = [:name, :file]
junit.report
else
puts "Couldn't find any test artifacts in path #{file_path}"
puts("Couldn't find any test artifacts in path #{file_path}")
end
4 changes: 2 additions & 2 deletions Gemfile
@@ -1,11 +1,11 @@
source "https://rubygems.org"
source("https://rubygems.org")

gem "xcode-install", ">= 2.2.1" # needed for running xcode-install related tests

gem "danger", ">= 4.2.1", "< 5.0.0"
gem "danger-junit", ">= 0.7.3", "< 1.0.0"

gemspec path: "."
gemspec(path: ".")

plugins_path = File.join(File.expand_path("..", __FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path)
22 changes: 11 additions & 11 deletions Rakefile
Expand Up @@ -4,25 +4,25 @@ GEMS = %w(fastlane danger-device_grid)

SECONDS_PER_DAY = 60 * 60 * 24

task :rubygems_admins do
task(:rubygems_admins) do
names = ["KrauseFx", "ohayon", "mpirri", "taquitos"]
(GEMS + ["krausefx-shenzhen", "commander-fastlane"]).each do |gem_name|
names.each do |name|
puts `gem owner #{gem_name} -a #{name}`
puts(`gem owner #{gem_name} -a #{name}`)
end
end
end

task :test_all do
task(:test_all) do
formatter = "--format progress"
formatter += " -r rspec_junit_formatter --format RspecJunitFormatter -o #{ENV['CIRCLE_TEST_REPORTS']}/rspec/fastlane-junit-results.xml" if ENV["CIRCLE_TEST_REPORTS"]
sh "rspec --pattern ./**/*_spec.rb #{formatter}"
sh("rspec --pattern ./**/*_spec.rb #{formatter}")
end

# Overwrite the default rake task
# since we use fastlane to deploy fastlane
task :push do
sh "bundle exec fastlane release"
task(:push) do
sh("bundle exec fastlane release")
end

#####################################################
Expand All @@ -31,10 +31,10 @@ end

def box(str)
l = str.length + 4
puts ''
puts '=' * l
puts '| ' + str + ' |'
puts '=' * l
puts('')
puts('=' * l)
puts('| ' + str + ' |')
puts('=' * l)
end

task default: :test_all
task(default: :test_all)
4 changes: 2 additions & 2 deletions bin/bin-proxy
Expand Up @@ -7,8 +7,8 @@ tool_name = File.basename($0)

full_params = ARGV.shelljoin

puts "[WARNING] You are calling #{tool_name} directly. Usage of the tool name without the `fastlane` prefix is deprecated in fastlane 2.0".yellow
puts "Please update your scripts to use `fastlane #{tool_name} #{full_params}` instead.".yellow
puts("[WARNING] You are calling #{tool_name} directly. Usage of the tool name without the `fastlane` prefix is deprecated in fastlane 2.0".yellow)
puts("Please update your scripts to use `fastlane #{tool_name} #{full_params}` instead.".yellow)

exec_arr = ["fastlane", tool_name] + ARGV

Expand Down
10 changes: 5 additions & 5 deletions bin/fastlane
@@ -1,20 +1,20 @@
#!/usr/bin/env ruby

if RUBY_VERSION < '2.0.0'
abort "fastlane requires Ruby 2.0.0 or higher"
abort("fastlane requires Ruby 2.0.0 or higher")
end

$LOAD_PATH.push File.expand_path("../../lib", __FILE__)
$LOAD_PATH.push(File.expand_path("../../lib", __FILE__))

require "fastlane/cli_tools_distributor"

if Fastlane::CLIToolsDistributor.running_version_command?
# This will print out the fastlane binary path right above the
# version number. Very often, users are not aware they have
# e.g. bundled fastlane installed
puts "fastlane installation at path:"
puts File.expand_path(__FILE__)
puts "-----------------------------"
puts("fastlane installation at path:")
puts(File.expand_path(__FILE__))
puts("-----------------------------")
end

Fastlane::CLIToolsDistributor.take_off
2 changes: 1 addition & 1 deletion cert/lib/cert/commands_generator.rb
Expand Up @@ -51,7 +51,7 @@ def run
end
end

default_command :create
default_command(:create)

run!
end
Expand Down
28 changes: 14 additions & 14 deletions cert/lib/cert/runner.rb
Expand Up @@ -13,17 +13,17 @@ def launch
run

installed = FastlaneCore::CertChecker.installed?(ENV["CER_FILE_PATH"])
UI.message "Verifying the certificate is properly installed locally..."
UI.message("Verifying the certificate is properly installed locally...")
UI.user_error!("Could not find the newly generated certificate installed", show_github_issues: true) unless installed
UI.success "Successfully installed certificate #{ENV['CER_CERTIFICATE_ID']}"
UI.success("Successfully installed certificate #{ENV['CER_CERTIFICATE_ID']}")
return ENV["CER_FILE_PATH"]
end

def login
UI.message "Starting login with user '#{Cert.config[:username]}'"
UI.message("Starting login with user '#{Cert.config[:username]}'")
Spaceship.login(Cert.config[:username], nil)
Spaceship.select_team
UI.message "Successfully logged in"
UI.message("Successfully logged in")
end

def run
Expand Down Expand Up @@ -57,24 +57,24 @@ def revoke_expired_certs!
to_revoke = expired_certs

if to_revoke.empty?
UI.success "No expired certificates were found to revoke! 👍"
UI.success("No expired certificates were found to revoke! 👍")
return
end

revoke_count = 0

to_revoke.each do |certificate|
begin
UI.message "#{certificate.id} #{certificate.name} has expired, revoking..."
UI.message("#{certificate.id} #{certificate.name} has expired, revoking...")
certificate.revoke!
revoke_count += 1
rescue => e
UI.error "An error occurred while revoking #{certificate.id} #{certificate.name}"
UI.error "#{e.message}\n#{e.backtrace.join("\n")}" if FastlaneCore::Globals.verbose?
UI.error("An error occurred while revoking #{certificate.id} #{certificate.name}")
UI.error("#{e.message}\n#{e.backtrace.join("\n")}") if FastlaneCore::Globals.verbose?
end
end

UI.success "#{revoke_count} expired certificate#{'s' if revoke_count != 1} #{revoke_count == 1 ? 'has' : 'have'} been revoked! 👍"
UI.success("#{revoke_count} expired certificate#{'s' if revoke_count != 1} #{revoke_count == 1 ? 'has' : 'have'} been revoked! 👍")
end

def expired_certs
Expand All @@ -97,7 +97,7 @@ def find_existing_cert
ENV["CER_CERTIFICATE_ID"] = certificate.id
ENV["CER_FILE_PATH"] = path

UI.success "Found the certificate #{certificate.id} (#{certificate.name}) which is installed on the local machine. Using this one."
UI.success("Found the certificate #{certificate.id} (#{certificate.name}) which is installed on the local machine. Using this one.")

return path
elsif File.exist?(private_key_path)
Expand All @@ -109,17 +109,17 @@ def find_existing_cert
ENV["CER_CERTIFICATE_ID"] = certificate.id
ENV["CER_FILE_PATH"] = path

UI.success "Found the cached certificate #{certificate.id} (#{certificate.name}). Using this one."
UI.success("Found the cached certificate #{certificate.id} (#{certificate.name}). Using this one.")

return path
else
UI.error "Certificate #{certificate.id} (#{certificate.name}) can't be found on your local computer"
UI.error("Certificate #{certificate.id} (#{certificate.name}) can't be found on your local computer")
end

File.delete(path) # as apparently this certificate is pretty useless without a private key
end

UI.important "Couldn't find an existing certificate... creating a new one"
UI.important("Couldn't find an existing certificate... creating a new one")
return nil
end

Expand Down Expand Up @@ -182,7 +182,7 @@ def create_certificate
ENV["CER_CERTIFICATE_ID"] = certificate.id
ENV["CER_FILE_PATH"] = cert_path

UI.success "Successfully generated #{certificate.id} which was imported to the local machine."
UI.success("Successfully generated #{certificate.id} which was imported to the local machine.")

return cert_path
end
Expand Down
2 changes: 1 addition & 1 deletion cert/spec/runner_spec.rb
Expand Up @@ -49,7 +49,7 @@
allow(FastlaneCore::CertChecker).to receive(:installed?).and_return(true)

expect(expired_cert).to receive(:revoke!)
expect(good_cert).to_not receive(:revoke!)
expect(good_cert).to_not(receive(:revoke!))

Cert.config = FastlaneCore::Configuration.create(Cert::Options.available_options, keychain_path: ".")
Cert::Runner.new.revoke_expired_certs!
Expand Down
22 changes: 11 additions & 11 deletions credentials_manager/lib/credentials_manager/account_manager.rb
Expand Up @@ -57,16 +57,16 @@ def password(ask_if_missing: true)
# @param force: if false, the user is asked before it gets deleted
# @return: Did the user decide to remove the old entry and enter a new password?
def invalid_credentials(force: false)
puts "The login credentials for '#{user}' seem to be wrong".red
puts("The login credentials for '#{user}' seem to be wrong".red)

if fetch_password_from_env
puts "The password was taken from the environment variable"
puts "Please make sure it is correct"
puts("The password was taken from the environment variable")
puts("Please make sure it is correct")
return false
end

if force || agree("Do you want to re-enter your password? (y/n)", true)
puts "Removing Keychain entry for user '#{user}'...".yellow
puts("Removing Keychain entry for user '#{user}'...".yellow)
remove_from_keychain
ask_for_login
return true
Expand Down Expand Up @@ -104,16 +104,16 @@ def options
private

def ask_for_login
puts "-------------------------------------------------------------------------------------".green
puts "Please provide your Apple Developer Program account credentials".green
puts "The login information you enter will be stored in your macOS Keychain".green
puts("-------------------------------------------------------------------------------------".green)
puts("Please provide your Apple Developer Program account credentials".green)
puts("The login information you enter will be stored in your macOS Keychain".green)
if default_prefix?
# We don't want to show this message, if we ask for the application specific password
# which has a different prefix
puts "You can also pass the password using the `FASTLANE_PASSWORD` environment variable".green
puts "More information about it on GitHub: https://github.com/fastlane/fastlane/tree/master/credentials_manager".green
puts("You can also pass the password using the `FASTLANE_PASSWORD` environment variable".green)
puts("More information about it on GitHub: https://github.com/fastlane/fastlane/tree/master/credentials_manager".green)
end
puts "-------------------------------------------------------------------------------------".green
puts("-------------------------------------------------------------------------------------".green)

if @user.to_s.length == 0
raise "Missing username, and running in non-interactive shell" if $stdout.isatty == false
Expand All @@ -138,7 +138,7 @@ def ask_for_login
if add_to_keychain
return true
else
puts "Could not store password in keychain".red
puts("Could not store password in keychain".red)
return false
end
end
Expand Down
22 changes: 11 additions & 11 deletions credentials_manager/lib/credentials_manager/appfile_config.rb
Expand Up @@ -9,15 +9,15 @@ def self.try_fetch_value(key)
begin
return self.new.data[key]
rescue => ex
puts ex.to_s
puts(ex.to_s)
return nil
end
nil
end

def self.default_path
["./fastlane/Appfile", "./.fastlane/Appfile", "./Appfile"].each do |current|
return current if File.exist? current
return current if File.exist?(current)
end
nil
end
Expand All @@ -36,10 +36,10 @@ def initialize(path = nil)

# From https://github.com/orta/danger/blob/master/lib/danger/Dangerfile.rb
if content.tr!('“”‘’‛', %(""'''))
puts "Your #{File.basename(path)} has had smart quotes sanitised. " \
puts("Your #{File.basename(path)} has had smart quotes sanitised. " \
'To avoid issues in the future, you should not use ' \
'TextEdit for editing it. If you are not using TextEdit, ' \
'you should turn off smart quotes in your editor of choice.'.red
'you should turn off smart quotes in your editor of choice.'.red)
end

# rubocop:disable Security/Eval
Expand All @@ -60,12 +60,12 @@ def print_debug_information(path: nil)
# this is necessary, as on the course of a fastlane run, the values might change, e.g. when using
# the `for_lane` keyword.

puts "Successfully loaded Appfile at path '#{path}'".yellow
puts("Successfully loaded Appfile at path '#{path}'".yellow)

self.data.each do |key, value|
puts "- #{key.to_s.cyan}: '#{value.to_s.green}'"
puts("- #{key.to_s.cyan}: '#{value.to_s.green}'")
end
puts "-------"
puts("-------")

self.class.already_printed_debug_information[self.data] = true
end
Expand Down Expand Up @@ -129,7 +129,7 @@ def json_key_data_raw(*args, &block)
end

def issuer(*args, &block)
puts "Appfile: DEPRECATED issuer: use json_key_file instead".red
puts("Appfile: DEPRECATED issuer: use json_key_file instead".red)
setter(:issuer, *args, &block)
end

Expand All @@ -138,7 +138,7 @@ def package_name(*args, &block)
end

def keyfile(*args, &block)
puts "Appfile: DEPRECATED keyfile: use json_key_file instead".red
puts("Appfile: DEPRECATED keyfile: use json_key_file instead".red)
setter(:keyfile, *args, &block)
end

Expand All @@ -152,8 +152,8 @@ def keyfile(*args, &block)
def for_lane(lane_name)
if lane_name.to_s.split(" ").count > 1
# That's the legacy syntax 'platform name'
puts "You use deprecated syntax '#{lane_name}' in your Appfile.".yellow
puts "Please follow the Appfile guide: https://docs.fastlane.tools/advanced/#appfile".yellow
puts("You use deprecated syntax '#{lane_name}' in your Appfile.".yellow)
puts("Please follow the Appfile guide: https://docs.fastlane.tools/advanced/#appfile".yellow)
platform, lane_name = lane_name.split(" ")

return unless platform == ENV["FASTLANE_PLATFORM_NAME"]
Expand Down
8 changes: 4 additions & 4 deletions credentials_manager/lib/credentials_manager/cli.rb
Expand Up @@ -17,16 +17,16 @@ def run
c.syntax = 'fastlane fastlane-credentials add'
c.description = 'Adds a fastlane credential to the keychain.'

c.option '--username username', String, 'Username to add.'
c.option '--password password', String, 'Password to add.'
c.option('--username username', String, 'Username to add.')
c.option('--password password', String, 'Password to add.')

c.action do |args, options|
username = options.username || ask('Username: ')
password = options.password || ask('Password: ') { |q| q.echo = '*' }

add(username, password)

puts "Credential #{username}:#{'*' * password.length} added to keychain."
puts("Credential #{username}:#{'*' * password.length} added to keychain.")
end
end

Expand All @@ -35,7 +35,7 @@ def run
c.syntax = 'fastlane fastlane-credentials remove'
c.description = 'Removes a fastlane credential from the keychain.'

c.option '--username username', String, 'Username to remove.'
c.option('--username username', String, 'Username to remove.')

c.action do |args, options|
username = options.username || ask('Username: ')
Expand Down

0 comments on commit 1a79353

Please sign in to comment.