Skip to content
This repository was archived by the owner on May 12, 2018. It is now read-only.

Commit f3c721c

Browse files
committed
rubocop install
1 parent 2a51728 commit f3c721c

20 files changed

+1091
-73
lines changed

.rubocop.yml

Lines changed: 1004 additions & 0 deletions
Large diffs are not rendered by default.

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ gem 'haml-rails'
3232

3333
# Background jobs
3434
gem 'slim'
35-
gem 'sinatra', :require => nil
35+
gem 'sinatra', require: nil
3636
gem 'sidekiq'
3737

3838
# Scheduled
@@ -107,6 +107,7 @@ group :development, :test do
107107
gem "simplecov", require: false
108108
gem 'coveralls', require: false
109109
gem 'minitest', '4.3.2'
110+
gem 'rubocop', '0.28.0', require: false
110111
end
111112

112113
group :test do

Gemfile.lock

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ GEM
3636
activerecord (>= 2.3.0)
3737
rake (>= 0.8.7)
3838
arel (4.0.2)
39+
ast (2.0.0)
40+
astrolabe (1.3.0)
41+
parser (>= 2.2.0.pre.3, < 3.0)
3942
axiom-types (0.0.5)
4043
descendants_tracker (~> 0.0.1)
4144
ice_nine (~> 0.9)
@@ -179,12 +182,15 @@ GEM
179182
multi_json (~> 1.3)
180183
multi_xml (~> 0.5)
181184
rack (~> 1.2)
185+
parser (2.2.0.2)
186+
ast (>= 1.1, < 3.0)
182187
pg (0.17.0)
183188
poltergeist (1.4.1)
184189
capybara (~> 2.1.0)
185190
cliver (~> 0.2.1)
186191
multi_json (~> 1.0)
187192
websocket-driver (>= 0.2.0)
193+
powerpack (0.0.9)
188194
protected_attributes (1.0.5)
189195
activemodel (>= 4.0.1, < 5.0)
190196
pry (0.9.12.4)
@@ -217,6 +223,7 @@ GEM
217223
activesupport (= 4.0.10)
218224
rake (>= 0.8.7)
219225
thor (>= 0.18.1, < 2.0)
226+
rainbow (2.0.0)
220227
raindrops (0.13.0)
221228
rake (10.3.2)
222229
rb-fsevent (0.9.3)
@@ -243,6 +250,13 @@ GEM
243250
rspec-core (~> 2.14.0)
244251
rspec-expectations (~> 2.14.0)
245252
rspec-mocks (~> 2.14.0)
253+
rubocop (0.28.0)
254+
astrolabe (~> 1.3)
255+
parser (>= 2.2.0.pre.7, < 3.0)
256+
powerpack (~> 0.0.6)
257+
rainbow (>= 1.99.1, < 3.0)
258+
ruby-progressbar (~> 1.4)
259+
ruby-progressbar (1.7.1)
246260
safe_yaml (0.9.7)
247261
sass (3.2.19)
248262
sass-rails (4.0.3)
@@ -365,6 +379,7 @@ DEPENDENCIES
365379
rb-fsevent
366380
rb-inotify
367381
rspec-rails
382+
rubocop (= 0.28.0)
368383
sass-rails (~> 4.0.0)
369384
settingslogic
370385
shoulda-matchers

Guardfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# A sample Guardfile
22
# More info at https://github.com/guard/guard#readme
33

4-
guard 'rspec', :version => 2 do
4+
guard 'rspec', version: 2 do
55
watch(%r{^spec/.+_spec\.rb$})
66
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
77
watch('spec/spec_helper.rb') { "spec" }
@@ -21,4 +21,3 @@ guard 'rspec', :version => 2 do
2121
watch(%r{^spec/acceptance/(.+)\.feature$})
2222
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
2323
end
24-

app/controllers/admin/application_controller.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ class Admin::ApplicationController < ApplicationController
22
before_filter :authenticate_user!
33
before_filter :authenticate_admin!
44
end
5-

app/controllers/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class ApplicationController < ActionController::Base
2-
rescue_from Network::UnauthorizedError, :with => :invalid_token
2+
rescue_from Network::UnauthorizedError, with: :invalid_token
33
before_filter :default_headers
44
before_filter :check_config
55

app/controllers/builds_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def show
2727

2828
respond_to do |format|
2929
format.html
30-
format.json {
30+
format.json do
3131
render json: @build.to_json(methods: :trace_html)
32-
}
32+
end
3333
end
3434
end
3535

app/models/build.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def retry(build)
105105
transition [:pending, :running] => :canceled
106106
end
107107

108-
after_transition :pending => :running do |build, transition|
108+
after_transition pending: :running do |build, transition|
109109
build.update_attributes started_at: Time.now
110110
end
111111

app/models/network.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class UnauthorizedError < StandardError; end
88
def authenticate(url, api_opts)
99
opts = {
1010
body: api_opts.to_json,
11-
headers: {"Content-Type" => "application/json"},
11+
headers: { "Content-Type" => "application/json" },
1212
}
1313

1414
endpoint = File.join(url, API_PREFIX, 'user')
@@ -20,7 +20,7 @@ def authenticate(url, api_opts)
2020
def authenticate_by_token(url, api_opts)
2121
opts = {
2222
query: api_opts,
23-
headers: {"Content-Type" => "application/json"},
23+
headers: { "Content-Type" => "application/json" },
2424
}
2525

2626
endpoint = File.join(url, API_PREFIX, 'user.json')
@@ -36,13 +36,13 @@ def projects(url, api_opts, scope = :owned)
3636

3737
opts = {
3838
query: api_opts,
39-
headers: {"Content-Type" => "application/json"},
39+
headers: { "Content-Type" => "application/json" },
4040
}
4141

4242
query = if scope == :owned
43-
'projects/owned.json'
43+
'projects/owned.json'
4444
else
45-
'projects.json'
45+
'projects.json'
4646
end
4747

4848
endpoint = File.join(url, API_PREFIX, query)
@@ -54,7 +54,7 @@ def projects(url, api_opts, scope = :owned)
5454
def project(url, api_opts, project_id)
5555
opts = {
5656
query: api_opts,
57-
headers: {"Content-Type" => "application/json"},
57+
headers: { "Content-Type" => "application/json" },
5858
}
5959

6060
query = "projects/#{project_id}.json"
@@ -68,7 +68,7 @@ def project(url, api_opts, project_id)
6868
def project_hooks(url, api_opts, project_id)
6969
opts = {
7070
query: api_opts,
71-
headers: {"Content-Type" => "application/json"},
71+
headers: { "Content-Type" => "application/json" },
7272
}
7373

7474
query = "projects/#{project_id}/hooks.json"
@@ -82,7 +82,7 @@ def project_hooks(url, api_opts, project_id)
8282
def enable_ci(url, project_id, ci_opts, token)
8383
opts = {
8484
body: ci_opts.to_json,
85-
headers: {"Content-Type" => "application/json"},
85+
headers: { "Content-Type" => "application/json" },
8686
}
8787

8888
query = "projects/#{project_id}/services/gitlab-ci.json?private_token=#{token}"
@@ -101,7 +101,7 @@ def enable_ci(url, project_id, ci_opts, token)
101101

102102
def disable_ci(url, project_id, token)
103103
opts = {
104-
headers: {"Content-Type" => "application/json"},
104+
headers: { "Content-Type" => "application/json" },
105105
}
106106

107107
query = "projects/#{project_id}/services/gitlab-ci.json?private_token=#{token}"

app/models/project_services/mail_service.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ def to_param
3535

3636
def fields
3737
[
38-
{type: 'text', name: 'email_recipients', label: 'Recipients', help: 'Whitespace-separated list of recipient addresses'},
39-
{type: 'checkbox', name: 'email_add_committer', label: 'Add committer to recipients list'},
40-
{type: 'checkbox', name: 'email_only_broken_builds', label: 'Notify only broken builds'}
38+
{ type: 'text', name: 'email_recipients', label: 'Recipients', help: 'Whitespace-separated list of recipient addresses' },
39+
{ type: 'checkbox', name: 'email_add_committer', label: 'Add committer to recipients list' },
40+
{ type: 'checkbox', name: 'email_only_broken_builds', label: 'Notify only broken builds' }
4141
]
4242
end
4343

@@ -47,12 +47,12 @@ def can_test?
4747
return false unless build.commit.project_recipients.any?
4848

4949
case build.status.to_sym
50-
when :failed
51-
true
52-
when :success
53-
!email_only_broken_builds
54-
else
55-
false
50+
when :failed
51+
true
52+
when :success
53+
!email_only_broken_builds
54+
else
55+
false
5656
end
5757
end
5858
end
@@ -65,11 +65,11 @@ def execute(build)
6565

6666
commit.project_recipients.each do |recipient|
6767
case build.status.to_sym
68-
when :success
69-
return if email_only_broken_builds
70-
mailer.build_success_email(build.id, recipient)
71-
when :failed
72-
mailer.build_fail_email(build.id, recipient)
68+
when :success
69+
return if email_only_broken_builds
70+
mailer.build_success_email(build.id, recipient)
71+
when :failed
72+
mailer.build_fail_email(build.id, recipient)
7373
end
7474
end
7575
end

app/models/project_services/slack_service.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ def help
3737

3838
def fields
3939
[
40-
{type: 'text', name: 'webhook', label: 'Webhook URL', placeholder: ''},
41-
{type: 'checkbox', name: 'notify_only_broken_builds', label: 'Notify only broken builds'}
40+
{ type: 'text', name: 'webhook', label: 'Webhook URL', placeholder: '' },
41+
{ type: 'checkbox', name: 'notify_only_broken_builds', label: 'Notify only broken builds' }
4242
]
4343
end
4444

4545
def can_test?
4646
# slack notification is useful only for builds either successful or failed
4747
project.commits.order(id: :desc).any? do |commit|
4848
case commit.status.to_sym
49-
when :failed
50-
true
51-
when :success
52-
!notify_only_broken_builds?
53-
else
54-
false
49+
when :failed
50+
true
51+
when :success
52+
!notify_only_broken_builds?
53+
else
54+
false
5555
end
5656
end
5757
end
@@ -62,11 +62,11 @@ def execute(build)
6262
return unless commit.builds_without_retry.include?(build)
6363

6464
case commit.status.to_sym
65-
when :failed
66-
when :success
67-
return if notify_only_broken_builds?
68-
else
69-
return
65+
when :failed
66+
when :success
67+
return if notify_only_broken_builds?
68+
else
69+
return
7070
end
7171

7272
message = SlackMessage.new(commit)

app/models/user_session.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def authenticate_via(options, &block)
2929
user = block.call(url, Network.new, options)
3030

3131
if user
32-
return User.new(user.merge({"url" => url}))
32+
return User.new(user.merge({ "url" => url }))
3333
else
3434
nil
3535
end

app/models/web_hook.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def execute(data)
3434
}
3535
WebHook.post(post_url,
3636
body: data.to_json,
37-
headers: {"Content-Type" => "application/json"},
37+
headers: { "Content-Type" => "application/json" },
3838
verify: false,
3939
basic_auth: auth)
4040
end

app/workers/slack_notifier_worker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ def perform(webhook_url, message, options={})
55
notifier = Slack::Notifier.new(webhook_url)
66
notifier.ping(message, options)
77
end
8-
end
8+
end

config/initializers/3_sidekiq.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
url: resque_url,
2020
namespace: 'resque:gitlab_ci'
2121
}
22-
end
22+
end

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@
7171
resources :builds, only: :index
7272
end
7373

74-
root :to => 'projects#index'
74+
root to: 'projects#index'
7575
end

lib/ansi2html.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ module Ansi2html
1515
}
1616

1717
STYLE_SWITCHES = {
18-
:bold => 0x01,
19-
:italic => 0x02,
20-
:underline => 0x04,
21-
:conceal => 0x08,
22-
:cross => 0x10,
18+
bold: 0x01,
19+
italic: 0x02,
20+
underline: 0x04,
21+
conceal: 0x08,
22+
cross: 0x10,
2323
}
2424

2525
def self.convert(ansi)

lib/api/api.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class API < Grape::API
55
version 'v1', using: :path
66

77
rescue_from ActiveRecord::RecordNotFound do
8-
rack_response({'message' => '404 Not found'}.to_json, 404)
8+
rack_response({ 'message' => '404 Not found' }.to_json, 404)
99
end
1010

1111
rescue_from :all do |exception|
@@ -18,7 +18,7 @@ class API < Grape::API
1818
message << " " << trace.join("\n ")
1919

2020
API.logger.add Logger::FATAL, message
21-
rack_response({'message' => '500 Internal Server Error'}, 500)
21+
rack_response({ 'message' => '500 Internal Server Error' }, 500)
2222
end
2323

2424
format :json

lib/api/helpers.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ module Helpers
66
def current_user
77
@current_user ||= begin
88
options = {
9-
:private_token => (params[PRIVATE_TOKEN_PARAM] || env[PRIVATE_TOKEN_HEADER]),
10-
:url => params[:url]
9+
private_token: (params[PRIVATE_TOKEN_PARAM] || env[PRIVATE_TOKEN_HEADER]),
10+
url: params[:url]
1111
}
1212
UserSession.new.authenticate_by_token(options)
1313
end
@@ -80,7 +80,7 @@ def not_allowed!
8080
end
8181

8282
def render_api_error!(message, status)
83-
error!({'message' => message}, status)
83+
error!({ 'message' => message }, status)
8484
end
8585

8686
private

0 commit comments

Comments
 (0)