Skip to content

Commit 4a38c7a

Browse files
author
vitalie
committed
Add rubocop
1 parent c472f33 commit 4a38c7a

File tree

12 files changed

+371
-202
lines changed

12 files changed

+371
-202
lines changed

.rubocop.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
require:
2+
- rubocop-performance
3+
- rubocop-rake
4+
- rubocop-rspec
5+
6+
AllCops:
7+
NewCops: enable
8+
Exclude:
9+
- vendor/**/*
10+
TargetRubyVersion: 2.5
11+
12+
Layout/LineLength:
13+
Enabled: true
14+
Max: 160
15+
16+
Metrics/ModuleLength:
17+
Enabled: false
18+
19+
Metrics/ClassLength:
20+
Enabled: false
21+
22+
Metrics/MethodLength:
23+
Enabled: false
24+
25+
Metrics/BlockLength:
26+
Enabled: false
27+
28+
Metrics/AbcSize:
29+
Enabled: false
30+
31+
Metrics/CyclomaticComplexity:
32+
Enabled: false
33+
34+
Style/Documentation:
35+
Enabled: false
36+
37+
Style/ClassVars:
38+
Enabled: false
39+
40+
Bundler/OrderedGems:
41+
Enabled: false
42+
43+
RSpec/FilePath:
44+
Enabled: false
45+
46+
RSpec/MultipleExpectations:
47+
Enabled: false
48+
49+
RSpec/MultipleMemoizedHelpers:
50+
Enabled: false
51+
52+
RSpec/ExampleLength:
53+
Enabled: false
54+
55+
RSpec/AnyInstance:
56+
Enabled: false

Gemfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
ruby '2.5.9'
46

5-
gem 'travis-support', git: 'https://github.com/travis-ci/travis-support', ref: '113cff17fe383bb72fcfae3a97a8ce98c228342f'
7+
gem 'travis-support', git: 'https://github.com/travis-ci/travis-support',
8+
ref: '113cff17fe383bb72fcfae3a97a8ce98c228342f'
69
gem 'travis-config', '~> 1.0.0'
710

811
gem 'sidekiq', '~> 4.0.0'
@@ -14,7 +17,7 @@ gem 'rake', '~> 12.3.3'
1417

1518
gem 'sentry-raven'
1619

17-
gem 'activesupport', '~> 4.1.11'
20+
gem 'activesupport', '~> 4.1.11'
1821

1922
gem 'metriks'
2023
gem 'metriks-librato_metrics'
@@ -29,10 +32,16 @@ group :development, :test do
2932
end
3033

3134
group :development do
32-
gem 'foreman', '~> 0.41.0'
35+
gem 'foreman', '~> 0.41.0'
36+
gem 'rubocop', require: false
37+
gem 'rubocop-performance', require: false
38+
gem 'rubocop-rake', require: false
39+
gem 'rubocop-rspec', require: false
3340
end
3441

3542
group :test do
3643
gem 'rack-test'
3744
gem 'timecop'
45+
gem 'simplecov', require: false
46+
gem 'simplecov-console', require: false
3847
end

Gemfile.lock

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@ GEM
2121
minitest (~> 5.1)
2222
thread_safe (~> 0.1)
2323
tzinfo (~> 1.1)
24+
ansi (1.5.0)
25+
ast (2.4.2)
2426
atomic (1.1.99)
2527
avl_tree (1.2.1)
2628
atomic (~> 1.1)
2729
coderay (1.1.2)
2830
concurrent-ruby (1.0.5)
2931
connection_pool (2.2.1)
3032
diff-lcs (1.5.0)
33+
docile (1.4.0)
3134
faraday (0.15.0)
3235
multipart-post (>= 1.2, < 3)
3336
foreman (0.41.0)
@@ -48,20 +51,28 @@ GEM
4851
multipart-post (2.0.0)
4952
mustermann (1.0.3)
5053
nio4r (2.5.8)
54+
parallel (1.23.0)
55+
parser (3.2.2.3)
56+
ast (~> 2.4.1)
57+
racc
5158
pry (0.11.3)
5259
coderay (~> 1.1.0)
5360
method_source (~> 0.9.0)
5461
puma (4.3.9)
5562
nio4r (~> 2.0)
63+
racc (1.7.1)
5664
rack (2.2.3)
5765
rack-protection (2.0.3)
5866
rack
5967
rack-test (1.0.0)
6068
rack (>= 1.0, < 3)
69+
rainbow (3.1.1)
6170
rake (12.3.3)
6271
redis (3.3.5)
6372
redis-namespace (1.6.0)
6473
redis (>= 3.0.4)
74+
regexp_parser (2.8.1)
75+
rexml (3.2.6)
6576
rspec (3.12.0)
6677
rspec-core (~> 3.12.0)
6778
rspec-expectations (~> 3.12.0)
@@ -75,17 +86,48 @@ GEM
7586
diff-lcs (>= 1.2.0, < 2.0)
7687
rspec-support (~> 3.12.0)
7788
rspec-support (3.12.1)
89+
rubocop (1.28.2)
90+
parallel (~> 1.10)
91+
parser (>= 3.1.0.0)
92+
rainbow (>= 2.2.2, < 4.0)
93+
regexp_parser (>= 1.8, < 3.0)
94+
rexml
95+
rubocop-ast (>= 1.17.0, < 2.0)
96+
ruby-progressbar (~> 1.7)
97+
unicode-display_width (>= 1.4.0, < 3.0)
98+
rubocop-ast (1.17.0)
99+
parser (>= 3.1.1.0)
100+
rubocop-performance (1.13.3)
101+
rubocop (>= 1.7.0, < 2.0)
102+
rubocop-ast (>= 0.4.0)
103+
rubocop-rake (0.6.0)
104+
rubocop (~> 1.0)
105+
rubocop-rspec (2.10.0)
106+
rubocop (~> 1.19)
107+
ruby-progressbar (1.13.0)
78108
sentry-raven (2.7.3)
79109
faraday (>= 0.7.6, < 1.0)
80110
sidekiq (4.0.2)
81111
concurrent-ruby (~> 1.0)
82112
connection_pool (~> 2.2, >= 2.2.0)
83113
redis (~> 3.2, >= 3.2.1)
114+
simplecov (0.22.0)
115+
docile (~> 1.1)
116+
simplecov-html (~> 0.11)
117+
simplecov_json_formatter (~> 0.1)
118+
simplecov-console (0.9.1)
119+
ansi
120+
simplecov
121+
terminal-table
122+
simplecov-html (0.12.3)
123+
simplecov_json_formatter (0.1.4)
84124
sinatra (2.0.3)
85125
mustermann (~> 1.0)
86126
rack (~> 2.0)
87127
rack-protection (= 2.0.3)
88128
tilt (~> 2.0)
129+
terminal-table (3.0.2)
130+
unicode-display_width (>= 1.1.1, < 3)
89131
thor (0.20.0)
90132
thread_safe (0.3.6)
91133
tilt (2.0.8)
@@ -94,6 +136,7 @@ GEM
94136
hashr (~> 2.0.0)
95137
tzinfo (1.2.5)
96138
thread_safe (~> 0.1)
139+
unicode-display_width (2.4.2)
97140
yajl-ruby (1.4.0)
98141

99142
PLATFORMS
@@ -111,8 +154,14 @@ DEPENDENCIES
111154
rake (~> 12.3.3)
112155
redis-namespace
113156
rspec
157+
rubocop
158+
rubocop-performance
159+
rubocop-rake
160+
rubocop-rspec
114161
sentry-raven
115162
sidekiq (~> 4.0.0)
163+
simplecov
164+
simplecov-console
116165
sinatra (~> 2.0.3)
117166
timecop
118167
travis-config (~> 1.0.0)

config.ru

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
$:.unshift File.expand_path('../lib', __FILE__)
1+
# frozen_string_literal: true
2+
3+
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
24

35
require 'travis/listener'
46

config/puma.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
2-
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
1+
# frozen_string_literal: true
2+
3+
workers Integer(ENV.fetch('WEB_CONCURRENCY', nil) || 2)
4+
threads_count = Integer(ENV.fetch('RAILS_MAX_THREADS', nil) || 5)
35
threads threads_count, threads_count
46

57
preload_app!
68

79
rackup DefaultRackup
8-
port ENV['PORT'] || 3000
9-
environment ENV['RACK_ENV'] || 'development'
10+
port ENV.fetch('PORT', nil) || 3000
11+
environment ENV.fetch('RACK_ENV', nil) || 'development'
1012

1113
on_worker_boot do
12-
if reporter = Travis::Metrics.reporter
14+
if (reporter = Travis::Metrics.reporter)
1315
reporter.stop
1416
reporter.start
1517
end
16-
end
18+
end

lib/travis/listener.rb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'travis/config'
24
require 'travis/support'
35
require 'travis/listener/app'
@@ -14,12 +16,14 @@ def config
1416

1517
module Listener
1618
class Config < Travis::Config
17-
define redis: { url: ENV.fetch('REDIS_URL', 'redis://localhost:6379'), namespace: 'sidekiq', network_timeout: 5 },
18-
redis_gatekeeper: { url: ENV.fetch('REDIS_GATEKEEPER_URL', 'redis://localhost:6379'), namespace: 'sidekiq', network_timeout: 5 },
19-
gator: { queue: ENV.fetch('SIDEKIQ_GATEKEEPER_QUEUE', 'build_requests') },
20-
sync: { queue: ENV.fetch('SIDEKIQ_SYNC_QUEUE', 'sync.gh_apps') },
21-
sentry: { },
22-
metrics: { reporter: 'librato' }
19+
define redis: { url: ENV.fetch('REDIS_URL', 'redis://localhost:6379'),
20+
namespace: 'sidekiq', network_timeout: 5 },
21+
redis_gatekeeper: { url: ENV.fetch('REDIS_GATEKEEPER_URL', 'redis://localhost:6379'),
22+
namespace: 'sidekiq', network_timeout: 5 },
23+
gator: { queue: ENV.fetch('SIDEKIQ_GATEKEEPER_QUEUE', 'build_requests') },
24+
sync: { queue: ENV.fetch('SIDEKIQ_SYNC_QUEUE', 'sync.gh_apps') },
25+
sentry: {},
26+
metrics: { reporter: 'librato' }
2327
end
2428

2529
class << self
@@ -28,11 +32,11 @@ def setup
2832
require 'raven'
2933
::Raven.configure do |config|
3034
config.dsn = Travis.config.sentry.dsn
31-
config.excluded_exceptions = %w{Sinatra::NotFound}
35+
config.excluded_exceptions = %w[Sinatra::NotFound]
3236
end
3337
end
3438

35-
Travis::Metrics.setup if ENV['RACK_ENV'] == "production"
39+
Travis::Metrics.setup if ENV.fetch('RACK_ENV', nil) == 'production'
3640
end
3741

3842
def disconnect

0 commit comments

Comments
 (0)