Skip to content

Commit

Permalink
[Rubocop] Fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiopelosin committed Aug 20, 2014
1 parent 4471377 commit 7b729ec
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
inherit_from:
# - .rubocop_todo.yml
- .rubocop_todo.yml
- .rubocop_cocoapods.yml
66 changes: 3 additions & 63 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
# This configuration was generated by `rubocop --auto-gen-config`
# on 2014-08-20 16:54:44 +0200 using RuboCop version 0.25.0.
# on 2014-08-20 17:00:42 +0200 using RuboCop version 0.25.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Cop supports --auto-correct.
Lint/RescueException:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Lint/UnusedMethodArgument:
Enabled: false

# Offense count: 1
Metrics/CyclomaticComplexity:
Max: 8

# Offense count: 7
# Offense count: 9
# Configuration parameters: AllowURI.
Metrics/LineLength:
Max: 96
Max: 105

# Offense count: 7
# Configuration parameters: CountComments.
Expand All @@ -33,11 +23,6 @@ Metrics/MethodLength:
Metrics/PerceivedComplexity:
Max: 9

# Offense count: 1
# Cop supports --auto-correct.
Style/Blocks:
Enabled: false

# Offense count: 1
Style/ClassVars:
Enabled: false
Expand All @@ -46,48 +31,3 @@ Style/ClassVars:
# Configuration parameters: Keywords.
Style/CommentAnnotation:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/EmptyLinesAroundBody:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
Style/NilComparison:
Enabled: false

# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/SpaceAfterComma:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
Style/SpaceInsideBlockBraces:
Enabled: true

# Offense count: 20
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/StringLiterals:
Enabled: false

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/TrailingBlankLines:
Enabled: false

# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
Style/TrailingComma:
Enabled: false
30 changes: 15 additions & 15 deletions lib/pod/command/trunk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def self.options
[
['--description=DESCRIPTION', 'An arbitrary description to ' \
'easily identify your session ' \
'later on.']
'later on.'],
].concat(super)
end

Expand All @@ -65,9 +65,9 @@ def run
body = {
'email' => @email,
'name' => @name,
'description' => @session_description
'description' => @session_description,
}.to_json
json = json(request_path(:post, "sessions", body, default_headers))
json = json(request_path(:post, 'sessions', body, default_headers))
save_token(json['token'])
# TODO UI.notice inserts an empty line :/
puts '[!] Please verify the session by clicking the link in the ' \
Expand Down Expand Up @@ -101,7 +101,7 @@ def validate!
end

def run
me = json(request_path(:get, "sessions", auth_headers))
me = json(request_path(:get, 'sessions', auth_headers))
owner = json(request_path(:get, "owners/#{me['email']}"))
UI.labeled 'Name', owner['name']
UI.labeled 'Email', owner['email']
Expand All @@ -117,7 +117,7 @@ def run
:created_at => formatted_time(session['created_at']),
:valid_until => formatted_time(session['valid_until']),
:created_from_ip => session['created_from_ip'],
:description => session['description']
:description => session['description'],
}
if Time.parse(session['valid_until']) <= Time.now.utc
hash[:color] = :red
Expand Down Expand Up @@ -206,7 +206,7 @@ class AddOwner < Trunk

self.arguments = [
CLAide::Argument.new('POD', true),
CLAide::Argument.new('OWNER-EMAIL', true)
CLAide::Argument.new('OWNER-EMAIL', true),
]

def initialize(argv)
Expand Down Expand Up @@ -255,12 +255,12 @@ class Push < Trunk
DESC

self.arguments = [
CLAide::Argument.new('PATH', false)
CLAide::Argument.new('PATH', false),
]

def self.options
[
["--allow-warnings", "Allows push even if there are lint warnings"],
['--allow-warnings', 'Allows push even if there are lint warnings'],
].concat(super)
end

Expand All @@ -287,7 +287,7 @@ def validate!

def run
validate_podspec
response = request_path(:post, "pods", spec.to_json, auth_headers)
response = request_path(:post, 'pods', spec.to_json, auth_headers)
url = response.headers['location'].first
json = json(request_url(:get, url, default_headers))

Expand All @@ -301,7 +301,7 @@ def run
end
UI.labeled 'Log messages', messages
rescue REST::Error => e
raise Informative, "There was an error pushing a new version " \
raise Informative, 'There was an error pushing a new version ' \
"to trunk: #{e.message}"
end

Expand Down Expand Up @@ -337,14 +337,14 @@ def validate_podspec
validator.only_errors = @allow_warnings
begin
validator.validate
rescue Exception
rescue
# TODO: We should add `CLAide::InformativeError#wraps_exception`
# which would include the original error message on `--verbose`.
# https://github.com/CocoaPods/CLAide/issues/31
raise Informative, "The podspec does not validate."
raise Informative, 'The podspec does not validate.'
end
unless validator.validated?
raise Informative, "The podspec does not validate."
raise Informative, 'The podspec does not validate.'
end
end
end
Expand Down Expand Up @@ -383,7 +383,7 @@ def print_error(body)
case error = json['error']
when Hash
lines = error.sort_by(&:first).map do |attr, messages|
attr = attr[0,1].upcase << attr[1..-1]
attr = attr[0, 1].upcase << attr[1..-1]
messages.sort.map do |message|
"- #{attr} #{message}."
end
Expand Down Expand Up @@ -413,7 +413,7 @@ def token
def default_headers
{
'Content-Type' => 'application/json; charset=utf-8',
'Accept' => 'application/json; charset=utf-8'
'Accept' => 'application/json; charset=utf-8',
}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/trunk.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "cocoapods/trunk/version"
require 'cocoapods/trunk/version'

module Cocoapods
module Trunk
Expand Down
2 changes: 1 addition & 1 deletion lib/trunk/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Cocoapods
module Trunk
VERSION = "0.1.4"
VERSION = '0.1.4'
end
end
7 changes: 3 additions & 4 deletions spec/command/trunk/addowner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

module Pod
describe Command::Trunk::AddOwner do
describe "CLAide" do
it "registers it self" do
Command.parse(%w{ trunk add-owner }).should.be.instance_of Command::Trunk::AddOwner
describe 'CLAide' do
it 'registers it self' do
Command.parse(%w( trunk add-owner )).should.be.instance_of Command::Trunk::AddOwner
end
end
end
end

9 changes: 4 additions & 5 deletions spec/command/trunk/me_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

module Pod
describe Command::Trunk::Me do
describe "CLAide" do
it "registers it self" do
Command.parse(%w{ trunk me }).should.be.instance_of Command::Trunk::Me
describe 'CLAide' do
it 'registers it self' do
Command.parse(%w( trunk me )).should.be.instance_of Command::Trunk::Me
end
end

it "should error if we don't have a token" do
Netrc.any_instance.stubs(:[]).returns(nil)
command = Command.parse(%w{ trunk me })
command = Command.parse(%w( trunk me ))
lambda { command.validate! }.should.raise CLAide::Help
end
end
end

20 changes: 10 additions & 10 deletions spec/command/trunk/push_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@

module Pod
describe Command::Trunk::Push do
describe "CLAide" do
it "registers it self" do
Command.parse(%w{ trunk push }).should.be.instance_of Command::Trunk::Push
describe 'CLAide' do
it 'registers it self' do
Command.parse(%w( trunk push )).should.be.instance_of Command::Trunk::Push
end
end

describe 'PATH' do
before {
before do
UI.output = ''
}
end
it 'defaults to the current directory' do
# Disable the podspec finding algorithm so we can check the raw path
Command::Trunk::Push.any_instance.stubs(:find_podspec_file) { |path| path }
command = Command.parse(%w{ trunk push })
command = Command.parse(%w( trunk push ))
command.instance_eval { @path }.should == '.'
end

Expand All @@ -25,10 +25,10 @@ def found_podspec_among_files(files)
Dir.mktmpdir do |dir|
files.each do |filename|
path = Pathname(dir) + filename
File.open(path, 'w') { }
File.open(path, 'w') {}
end
# Execute `pod trunk push` with this dir as parameter
command = Command.parse(%w{ trunk push } + [dir])
command = Command.parse(%w( trunk push ) + [dir])
path = command.instance_eval { @path }
return path ? File.basename(path) : nil
end
Expand All @@ -46,13 +46,13 @@ def found_podspec_among_files(files)

it 'should warn when no podspec found in a given directory' do
files = %w(foo bar baz)
found_podspec_among_files(files).should == nil
found_podspec_among_files(files).should.nil?
UI.output.should.match /No podspec found in directory/
end

it 'should warn when multiple podspecs found in a given directory' do
files = %w(foo bar.podspec bar.podspec.json baz)
found_podspec_among_files(files).should == nil
found_podspec_among_files(files).should.nil?
UI.output.should.match /Multiple podspec files in directory/
end
end
Expand Down
7 changes: 3 additions & 4 deletions spec/command/trunk/register_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

module Pod
describe Command::Trunk::Register do
describe "CLAide" do
it "registers it self" do
Command.parse(%w{ trunk register }).should.be.instance_of Command::Trunk::Register
describe 'CLAide' do
it 'registers it self' do
Command.parse(%w( trunk register )).should.be.instance_of Command::Trunk::Register
end
end
end
end

7 changes: 3 additions & 4 deletions spec/command/trunk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

module Pod
describe Command::Trunk do
describe "CLAide" do
it "registers it self" do
Command.parse(%w{ trunk }).should.be.instance_of Command::Trunk
describe 'CLAide' do
it 'registers it self' do
Command.parse(%w( trunk )).should.be.instance_of Command::Trunk
end
end
end
end

3 changes: 1 addition & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#-----------------------------------------------------------------------------#

module Pod

# Disable the wrapping so the output is deterministic in the tests.
#
UI.disable_wrap = true
Expand All @@ -48,7 +47,7 @@ def puts(message = '')
@output << "#{message}\n"
end

def warn(message = '', actions = [])
def warn(message = '', _actions = [])
@warnings << "#{message}\n"
end

Expand Down

0 comments on commit 7b729ec

Please sign in to comment.