Skip to content

Commit

Permalink
Add Rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
lazebny committed Dec 23, 2016
1 parent dfdaa82 commit b268be1
Show file tree
Hide file tree
Showing 143 changed files with 2,416 additions and 2,107 deletions.
36 changes: 36 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This is the configuration used to check the rubocop source code.

require: rubocop-rspec
inherit_from:
- .rubocop_todo.yml

AllCops:
Exclude:
- 'docker-compose/**/*'
- 'examples/**/*'
- 'tmp/**/*'
TargetRubyVersion: 2.0
# DefaultFormatter: fuubar
Style/Alias:
Enabled: false

Style/Documentation:
Enabled: false

Style/Encoding:
Enabled: false

Style/NumericLiterals:
Enabled: false

Metrics/LineLength:
Max: 100
Exclude:
- '*.gemspec'

Style/RegexpLiteral:
EnforcedStyle: mixed

Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: consistent_comma

186 changes: 186 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-11-20 15:49:33 +0000 using RuboCop version 0.45.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.

require: rubocop-rspec

# Offense count: 2
Lint/AmbiguousRegexpLiteral:
Exclude:
- 'lib/flipper/instrumentation/metriks.rb'
- 'lib/flipper/instrumentation/statsd.rb'

# Offense count: 6
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
Exclude:
- 'lib/flipper/adapters/active_record.rb'
- 'lib/flipper/adapters/sequel.rb'
- 'lib/flipper/feature.rb'
- 'lib/flipper/gate_values.rb'

# Offense count: 1
Lint/Eval:
Exclude:
- 'flipper.gemspec'

# Offense count: 3
Lint/HandleExceptions:
Exclude:
- 'spec/flipper/adapters/mongo_spec.rb'
- 'test/adapters/mongo_test.rb'
- 'test/helper.rb'

# Offense count: 24
Lint/ShadowingOuterLocalVariable:
Exclude:
- 'lib/flipper/adapters/active_record.rb'
- 'lib/flipper/adapters/instrumented.rb'
- 'lib/flipper/adapters/sequel.rb'
- 'spec/flipper/api/v1/actions/actors_gate_spec.rb'
- 'spec/flipper/api/v1/actions/percentage_of_actors_gate_spec.rb'
- 'spec/flipper/api/v1/actions/percentage_of_time_gate_spec.rb'
- 'spec/flipper/dsl_spec.rb'
- 'spec/flipper/feature_spec.rb'
- 'spec/flipper/types/group_spec.rb'

# Offense count: 26
Lint/UselessAssignment:
Exclude:
- 'lib/flipper/instrumentation/log_subscriber.rb'
- 'lib/flipper/instrumentation/subscriber.rb'
- 'lib/flipper/ui/actions/groups_gate.rb'
- 'spec/flipper/api/action_spec.rb'
- 'spec/flipper/dsl_spec.rb'
- 'spec/flipper/feature_spec.rb'
- 'spec/flipper/gates/group_spec.rb'
- 'spec/flipper/instrumentation/metriks_subscriber_spec.rb'
- 'spec/flipper/instrumentation/statsd_subscriber_spec.rb'
- 'spec/flipper_spec.rb'
- 'test/helper.rb'

# Offense count: 27
Metrics/AbcSize:
Max: 30

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/BlockLength:
Max: 195

# Offense count: 4
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 178

# Offense count: 39
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 23

# Offense count: 65
# Configuration parameters: Max.
RSpec/ExampleLength:
Enabled: false

# Offense count: 2
# Configuration parameters: CustomTransform.
RSpec/FilePath:
Exclude:
- 'spec/flipper/adapters/pstore_spec.rb'
- 'spec/integration_spec.rb'

# Offense count: 91
RSpec/InstanceVariable:
Exclude:
- 'spec/flipper/adapters/operation_logger_spec.rb'
- 'spec/flipper/dsl_spec.rb'
- 'spec/flipper/feature_spec.rb'
- 'spec/flipper/instrumentation/log_subscriber_spec.rb'
- 'spec/flipper/ui/actions/add_feature_spec.rb'
- 'spec/flipper/ui/actions/features_spec.rb'
- 'spec/flipper/ui/decorators/feature_spec.rb'
- 'spec/flipper/ui/decorators/gate_spec.rb'
- 'spec/flipper/ui_spec.rb'
- 'spec/flipper_spec.rb'
- 'spec/integration_spec.rb'

# Offense count: 15
# Configuration parameters: IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Exclude:
- 'spec/flipper/api/v1/actions/features_spec.rb'
- 'spec/flipper/dsl_spec.rb'
- 'spec/flipper/feature_spec.rb'
- 'spec/flipper/types/group_spec.rb'
- 'spec/flipper_spec.rb'
- 'spec/integration_spec.rb'

# Offense count: 2
Style/AccessorMethodName:
Exclude:
- 'lib/flipper/adapters/memory.rb'
- 'lib/flipper/adapters/pstore.rb'

# Offense count: 7
Style/ConstantName:
Exclude:
- 'lib/flipper.rb'
- 'lib/flipper/adapters/dalli.rb'
- 'lib/flipper/adapters/memoizable.rb'
- 'lib/flipper/adapters/memory.rb'
- 'lib/flipper/adapters/mongo.rb'
- 'lib/flipper/adapters/pstore.rb'
- 'lib/flipper/adapters/redis.rb'

# Offense count: 3
Style/DoubleNegation:
Exclude:
- 'lib/flipper/adapters/memoizable.rb'
- 'lib/flipper/gates/boolean.rb'
- 'lib/flipper/typecast.rb'

# Offense count: 7
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
Style/FileName:
Exclude:
- 'lib/flipper-active_record.rb'
- 'lib/flipper-api.rb'
- 'lib/flipper-dalli.rb'
- 'lib/flipper-mongo.rb'
- 'lib/flipper-redis.rb'
- 'lib/flipper-sequel.rb'
- 'lib/flipper-ui.rb'

# Offense count: 2
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: format, sprintf, percent
Style/FormatString:
Exclude:
- 'lib/flipper/instrumentation/log_subscriber.rb'

# Offense count: 10
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'lib/flipper/api/v1/actions/percentage_of_actors_gate.rb'
- 'lib/flipper/api/v1/actions/percentage_of_time_gate.rb'
- 'lib/flipper/gate_values.rb'
- 'lib/flipper/instrumentation/statsd_subscriber.rb'
- 'lib/flipper/instrumentation/subscriber.rb'
- 'lib/flipper/registry.rb'
- 'lib/flipper/typecast.rb'

# Offense count: 1
Style/IfInsideElse:
Exclude:
- 'lib/flipper/gates/actor.rb'

# Offense count: 1
Style/MethodMissing:
Exclude:
- 'lib/flipper/types/actor.rb'
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ rvm:
- 2.2.4
bundler_args: --without guard
before_script: gem install bundler -v 1.10.6 && sudo service redis-server status && sudo service mongodb status
script: bundle exec rake
script: bundle exec rubocop && bundle exec rake
services:
- redis-server
- mongodb
Expand Down
8 changes: 5 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
source 'https://rubygems.org'
gemspec :name => 'flipper'
gemspec name: 'flipper'

Dir['flipper-*.gemspec'].each do |gemspec|
plugin = gemspec.scan(/flipper-(.*)\.gemspec/).flatten.first
gemspec(:name => "flipper-#{plugin}", :development_group => plugin)
gemspec(name: "flipper-#{plugin}", development_group: plugin)
end

gem 'rake', '~> 10.4.2'
Expand All @@ -13,8 +13,10 @@ gem 'statsd-ruby', '~> 1.2.1'
gem 'rspec', '~> 3.0'
gem 'rack-test', '~> 0.6.3'
gem 'sqlite3', '~> 1.3.11'
gem 'rails', "~> #{ENV["RAILS_VERSION"] || '4.2.5'}"
gem 'rails', "~> #{ENV['RAILS_VERSION'] || '4.2.5'}"
gem 'minitest', '~> 5.8.0'
gem 'rubocop', '~> 0.45.0'
gem 'rubocop-rspec', '= 1.5.1'

# for active support tests in test/ and only needed for ruby 2.2.x
gem 'test-unit', '~> 3.0'
Expand Down
26 changes: 13 additions & 13 deletions Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ guard 'bundler' do
end

rspec_options = {
:all_after_pass => false,
:all_on_start => false,
:failed_mode => :keep,
:cmd => "bundle exec rspec",
all_after_pass: false,
all_on_start: false,
failed_mode: :keep,
cmd: 'bundle exec rspec',
}

guard 'rspec', rspec_options do
watch(%r{^spec/.+_spec\.rb$}) { "spec" }
watch(%r{^lib/(.+)\.rb$}) { "spec" }
watch(%r{shared_adapter_specs\.rb$}) { "spec" }
watch('spec/helper.rb') { "spec" }
watch(%r{^spec/.+_spec\.rb$}) { 'spec' }
watch(%r{^lib/(.+)\.rb$}) { 'spec' }
watch(/shared_adapter_specs\.rb$/) { 'spec' }
watch('spec/helper.rb') { 'spec' }
end

coffee_options = {
:input => 'lib/flipper/ui/assets/javascripts',
:output => 'lib/flipper/ui/public/js',
:all_on_start => false,
input: 'lib/flipper/ui/assets/javascripts',
output: 'lib/flipper/ui/public/js',
all_on_start: false,
}
guard 'coffeescript', coffee_options

sass_options = {
:input => 'lib/flipper/ui/assets/stylesheets',
:output => 'lib/flipper/ui/public/css',
input: 'lib/flipper/ui/assets/stylesheets',
output: 'lib/flipper/ui/public/css',
}
guard 'sass', sass_options
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ Of course there are more [examples for you to peruse](examples/). You could also

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
3. Check your changes with Rubocop tests (`bundle exec rubocop -aD'`)
4. Commit your changes (`git commit -am 'Added some feature'`)
5. Push to the branch (`git push origin my-new-feature`)
6. Create new Pull Request

## Releasing

Expand Down
26 changes: 13 additions & 13 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env rake
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'rake/testtask'
require "flipper/version"
require 'flipper/version'

# gem install pkg/*.gem
# gem uninstall flipper flipper-ui flipper-redis
Expand All @@ -16,34 +16,34 @@ task :build do
end

desc 'Tags version, pushes to remote, and pushes gem'
task :release => :build do
task release: :build do
sh 'git', 'tag', "v#{Flipper::VERSION}"
sh "git push origin master"
sh 'git push origin master'
sh "git push origin v#{Flipper::VERSION}"
sh "ls pkg/*.gem | xargs -n 1 gem push"
sh 'ls pkg/*.gem | xargs -n 1 gem push'
end

require "rspec/core/rake_task"
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = %w(--color)
end

namespace :spec do
desc "Run specs for UI queue"
desc 'Run specs for UI queue'
RSpec::Core::RakeTask.new(:ui) do |t|
t.rspec_opts = %w(--color)
t.pattern = ["spec/flipper/ui/**/*_spec.rb", "spec/flipper/ui_spec.rb"]
t.pattern = ['spec/flipper/ui/**/*_spec.rb', 'spec/flipper/ui_spec.rb']
end
end

Rake::TestTask.new do |t|
t.libs = ['lib', 'test']
t.pattern = "test/**/*_test.rb"
t.libs = %w(lib test)
t.pattern = 'test/**/*_test.rb'
end

Rake::TestTask.new(:shared_test) do |t|
t.libs = ['lib', 'test']
t.pattern = "lib/flipper/shared/test/**_test.rb"
t.libs = %w(lib test)
t.pattern = 'lib/flipper/shared/test/**_test.rb'
end

task :default => [:spec, :test, :shared_test]
task default: [:spec, :test, :shared_test]
Loading

0 comments on commit b268be1

Please sign in to comment.