Skip to content

Commit

Permalink
Add rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalie committed Aug 24, 2023
1 parent c472f33 commit 4a38c7a
Show file tree
Hide file tree
Showing 12 changed files with 371 additions and 202 deletions.
56 changes: 56 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
require:
- rubocop-performance
- rubocop-rake
- rubocop-rspec

AllCops:
NewCops: enable
Exclude:
- vendor/**/*
TargetRubyVersion: 2.5

Layout/LineLength:
Enabled: true
Max: 160

Metrics/ModuleLength:
Enabled: false

Metrics/ClassLength:
Enabled: false

Metrics/MethodLength:
Enabled: false

Metrics/BlockLength:
Enabled: false

Metrics/AbcSize:
Enabled: false

Metrics/CyclomaticComplexity:
Enabled: false

Style/Documentation:
Enabled: false

Style/ClassVars:
Enabled: false

Bundler/OrderedGems:
Enabled: false

RSpec/FilePath:
Enabled: false

RSpec/MultipleExpectations:
Enabled: false

RSpec/MultipleMemoizedHelpers:
Enabled: false

RSpec/ExampleLength:
Enabled: false

RSpec/AnyInstance:
Enabled: false
15 changes: 12 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# frozen_string_literal: true

source 'https://rubygems.org'

ruby '2.5.9'

gem 'travis-support', git: 'https://github.com/travis-ci/travis-support', ref: '113cff17fe383bb72fcfae3a97a8ce98c228342f'
gem 'travis-support', git: 'https://github.com/travis-ci/travis-support',
ref: '113cff17fe383bb72fcfae3a97a8ce98c228342f'
gem 'travis-config', '~> 1.0.0'

gem 'sidekiq', '~> 4.0.0'
Expand All @@ -14,7 +17,7 @@ gem 'rake', '~> 12.3.3'

gem 'sentry-raven'

gem 'activesupport', '~> 4.1.11'
gem 'activesupport', '~> 4.1.11'

gem 'metriks'
gem 'metriks-librato_metrics'
Expand All @@ -29,10 +32,16 @@ group :development, :test do
end

group :development do
gem 'foreman', '~> 0.41.0'
gem 'foreman', '~> 0.41.0'
gem 'rubocop', require: false
gem 'rubocop-performance', require: false
gem 'rubocop-rake', require: false
gem 'rubocop-rspec', require: false
end

group :test do
gem 'rack-test'
gem 'timecop'
gem 'simplecov', require: false
gem 'simplecov-console', require: false
end
49 changes: 49 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
ansi (1.5.0)
ast (2.4.2)
atomic (1.1.99)
avl_tree (1.2.1)
atomic (~> 1.1)
coderay (1.1.2)
concurrent-ruby (1.0.5)
connection_pool (2.2.1)
diff-lcs (1.5.0)
docile (1.4.0)
faraday (0.15.0)
multipart-post (>= 1.2, < 3)
foreman (0.41.0)
Expand All @@ -48,20 +51,28 @@ GEM
multipart-post (2.0.0)
mustermann (1.0.3)
nio4r (2.5.8)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
racc
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
puma (4.3.9)
nio4r (~> 2.0)
racc (1.7.1)
rack (2.2.3)
rack-protection (2.0.3)
rack
rack-test (1.0.0)
rack (>= 1.0, < 3)
rainbow (3.1.1)
rake (12.3.3)
redis (3.3.5)
redis-namespace (1.6.0)
redis (>= 3.0.4)
regexp_parser (2.8.1)
rexml (3.2.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
Expand All @@ -75,17 +86,48 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
rubocop (1.28.2)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.17.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.17.0)
parser (>= 3.1.1.0)
rubocop-performance (1.13.3)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.10.0)
rubocop (~> 1.19)
ruby-progressbar (1.13.0)
sentry-raven (2.7.3)
faraday (>= 0.7.6, < 1.0)
sidekiq (4.0.2)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
redis (~> 3.2, >= 3.2.1)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-console (0.9.1)
ansi
simplecov
terminal-table
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
sinatra (2.0.3)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.3)
tilt (~> 2.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (0.20.0)
thread_safe (0.3.6)
tilt (2.0.8)
Expand All @@ -94,6 +136,7 @@ GEM
hashr (~> 2.0.0)
tzinfo (1.2.5)
thread_safe (~> 0.1)
unicode-display_width (2.4.2)
yajl-ruby (1.4.0)

PLATFORMS
Expand All @@ -111,8 +154,14 @@ DEPENDENCIES
rake (~> 12.3.3)
redis-namespace
rspec
rubocop
rubocop-performance
rubocop-rake
rubocop-rspec
sentry-raven
sidekiq (~> 4.0.0)
simplecov
simplecov-console
sinatra (~> 2.0.3)
timecop
travis-config (~> 1.0.0)
Expand Down
4 changes: 3 additions & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
$:.unshift File.expand_path('../lib', __FILE__)
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path('lib', __dir__)

require 'travis/listener'

Expand Down
14 changes: 8 additions & 6 deletions config/puma.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
# frozen_string_literal: true

workers Integer(ENV.fetch('WEB_CONCURRENCY', nil) || 2)
threads_count = Integer(ENV.fetch('RAILS_MAX_THREADS', nil) || 5)
threads threads_count, threads_count

preload_app!

rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
port ENV.fetch('PORT', nil) || 3000
environment ENV.fetch('RACK_ENV', nil) || 'development'

on_worker_boot do
if reporter = Travis::Metrics.reporter
if (reporter = Travis::Metrics.reporter)
reporter.stop
reporter.start
end
end
end
20 changes: 12 additions & 8 deletions lib/travis/listener.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'travis/config'
require 'travis/support'
require 'travis/listener/app'
Expand All @@ -14,12 +16,14 @@ def config

module Listener
class Config < Travis::Config
define redis: { url: ENV.fetch('REDIS_URL', 'redis://localhost:6379'), namespace: 'sidekiq', network_timeout: 5 },
redis_gatekeeper: { url: ENV.fetch('REDIS_GATEKEEPER_URL', 'redis://localhost:6379'), namespace: 'sidekiq', network_timeout: 5 },
gator: { queue: ENV.fetch('SIDEKIQ_GATEKEEPER_QUEUE', 'build_requests') },
sync: { queue: ENV.fetch('SIDEKIQ_SYNC_QUEUE', 'sync.gh_apps') },
sentry: { },
metrics: { reporter: 'librato' }
define redis: { url: ENV.fetch('REDIS_URL', 'redis://localhost:6379'),
namespace: 'sidekiq', network_timeout: 5 },
redis_gatekeeper: { url: ENV.fetch('REDIS_GATEKEEPER_URL', 'redis://localhost:6379'),
namespace: 'sidekiq', network_timeout: 5 },
gator: { queue: ENV.fetch('SIDEKIQ_GATEKEEPER_QUEUE', 'build_requests') },
sync: { queue: ENV.fetch('SIDEKIQ_SYNC_QUEUE', 'sync.gh_apps') },
sentry: {},
metrics: { reporter: 'librato' }
end

class << self
Expand All @@ -28,11 +32,11 @@ def setup
require 'raven'
::Raven.configure do |config|
config.dsn = Travis.config.sentry.dsn
config.excluded_exceptions = %w{Sinatra::NotFound}
config.excluded_exceptions = %w[Sinatra::NotFound]
end
end

Travis::Metrics.setup if ENV['RACK_ENV'] == "production"
Travis::Metrics.setup if ENV.fetch('RACK_ENV', nil) == 'production'
end

def disconnect
Expand Down
Loading

0 comments on commit 4a38c7a

Please sign in to comment.