Skip to content

Commit

Permalink
Make rubocop pass again with updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Jan 4, 2020
1 parent 40e57f3 commit cae3f8c
Show file tree
Hide file tree
Showing 25 changed files with 72 additions and 81 deletions.
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Style/GuardClause:
Style/IfUnlessModifier:
Enabled: false

Metrics/LineLength:
Layout/LineLength:
Max: 100

Style/RegexpLiteral:
Expand All @@ -48,5 +48,5 @@ Style/TrailingCommaInHashLiteral:
RSpec/InstanceVariable:
Enabled: false

Lint/HandleExceptions:
Lint/SuppressedException:
Enabled: false
12 changes: 6 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Gemspec/OrderedDependencies:
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/AlignHash:
Layout/HashAlignment:
Exclude:
- 'lib/flipper/typecast.rb'

Expand Down Expand Up @@ -81,7 +81,7 @@ Layout/EmptyLinesAroundExceptionHandlingKeywords:
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: squiggly, active_support, powerpack, unindent
Layout/IndentHeredoc:
Layout/HeredocIndentation:
Exclude:
- 'test/generators/flipper/active_record_generator_test.rb'

Expand Down Expand Up @@ -138,13 +138,13 @@ Lint/ShadowingOuterLocalVariable:

# Offense count: 2
# Cop supports --auto-correct.
Lint/UnneededCopDisableDirective:
Lint/RedundantCopDisableDirective:
Exclude:
- 'spec/flipper/adapter_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Lint/UnneededRequireStatement:
Lint/RedundantRequireStatement:
Exclude:
- 'lib/flipper/registry.rb'

Expand Down Expand Up @@ -174,13 +174,13 @@ Metrics/BlockLength:
# Offense count: 11
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 150
Max: 160

# Offense count: 20
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Layout/LineLength:
Max: 251

# Offense count: 59
Expand Down
2 changes: 1 addition & 1 deletion flipper-active_record.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
'lib/flipper/version.rb',
]
gem.files = `git ls-files`.split("\n").select(&flipper_active_record_files) + extra_files
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_active_record_files) # rubocop:disable Metrics/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_active_record_files) # rubocop:disable Layout/LineLength
gem.name = 'flipper-active_record'
gem.require_paths = ['lib']
gem.version = Flipper::VERSION
Expand Down
4 changes: 2 additions & 2 deletions flipper-active_support_cache_store.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Gem::Specification.new do |gem|
gem.license = 'MIT'
gem.homepage = 'https://github.com/jnunemaker/flipper'

gem.files = `git ls-files`.split("\n").select(&flipper_active_support_cache_store_files) + ['lib/flipper/version.rb'] # rubocop:disable Metrics/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_active_support_cache_store_files) # rubocop:disable Metrics/LineLength
gem.files = `git ls-files`.split("\n").select(&flipper_active_support_cache_store_files) + ['lib/flipper/version.rb'] # rubocop:disable Layout/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_active_support_cache_store_files) # rubocop:disable Layout/LineLength
gem.name = 'flipper-active_support_cache_store'
gem.require_paths = ['lib']
gem.version = Flipper::VERSION
Expand Down
4 changes: 2 additions & 2 deletions flipper-api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Gem::Specification.new do |gem|
gem.description = 'Rack middleware that provides an API for the flipper gem.'
gem.license = 'MIT'
gem.homepage = 'https://github.com/jnunemaker/flipper'
gem.files = `git ls-files`.split("\n").select(&flipper_api_files) + ['lib/flipper/version.rb'] # rubocop:disable Metrics/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_api_files) # rubocop:disable Metrics/LineLength
gem.files = `git ls-files`.split("\n").select(&flipper_api_files) + ['lib/flipper/version.rb'] # rubocop:disable Layout/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_api_files) # rubocop:disable Layout/LineLength
gem.name = 'flipper-api'
gem.require_paths = ['lib']
gem.version = Flipper::VERSION
Expand Down
2 changes: 1 addition & 1 deletion flipper-cloud.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
'lib/flipper/version.rb',
]
gem.files = `git ls-files`.split("\n").select(&flipper_cloud_files) + extra_files
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_cloud_files) # rubocop:disable Metrics/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_cloud_files) # rubocop:disable Layout/LineLength
gem.name = 'flipper-cloud'
gem.require_paths = ['lib']
gem.version = Flipper::VERSION
Expand Down
4 changes: 2 additions & 2 deletions flipper-dalli.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Gem::Specification.new do |gem|
gem.license = 'MIT'
gem.homepage = 'https://github.com/jnunemaker/flipper'

gem.files = `git ls-files`.split("\n").select(&flipper_dalli_files) + ['lib/flipper/version.rb'] # rubocop:disable Metrics/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_dalli_files) # rubocop:disable Metrics/LineLength
gem.files = `git ls-files`.split("\n").select(&flipper_dalli_files) + ['lib/flipper/version.rb'] # rubocop:disable Layout/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_dalli_files) # rubocop:disable Layout/LineLength
gem.name = 'flipper-dalli'
gem.require_paths = ['lib']
gem.version = Flipper::VERSION
Expand Down
4 changes: 2 additions & 2 deletions flipper-moneta.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Gem::Specification.new do |gem|
gem.license = 'MIT'
gem.homepage = 'https://github.com/jnunemaker/flipper'

gem.files = `git ls-files`.split("\n").select(&flipper_moneta_files) + ['lib/flipper/version.rb'] # rubocop:disable Metrics/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_moneta_files) # rubocop:disable Metrics/LineLength
gem.files = `git ls-files`.split("\n").select(&flipper_moneta_files) + ['lib/flipper/version.rb'] # rubocop:disable Layout/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_moneta_files) # rubocop:disable Layout/LineLength
gem.name = 'flipper-moneta'
gem.require_paths = ['lib']
gem.version = Flipper::VERSION
Expand Down
4 changes: 2 additions & 2 deletions flipper-mongo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Gem::Specification.new do |gem|
gem.license = 'MIT'
gem.homepage = 'https://github.com/jnunemaker/flipper'

gem.files = `git ls-files`.split("\n").select(&flipper_mongo_files) + ['lib/flipper/version.rb'] # rubocop:disable Metrics/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_mongo_files) # rubocop:disable Metrics/LineLength
gem.files = `git ls-files`.split("\n").select(&flipper_mongo_files) + ['lib/flipper/version.rb'] # rubocop:disable Layout/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_mongo_files) # rubocop:disable Layout/LineLength
gem.name = 'flipper-mongo'
gem.require_paths = ['lib']
gem.version = Flipper::VERSION
Expand Down
4 changes: 2 additions & 2 deletions flipper-redis.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Gem::Specification.new do |gem|
gem.license = 'MIT'
gem.homepage = 'https://github.com/jnunemaker/flipper'

gem.files = `git ls-files`.split("\n").select(&flipper_redis_files) + ['lib/flipper/version.rb'] # rubocop:disable Metrics/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_redis_files) # rubocop:disable Metrics/LineLength
gem.files = `git ls-files`.split("\n").select(&flipper_redis_files) + ['lib/flipper/version.rb'] # rubocop:disable Layout/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_redis_files) # rubocop:disable Layout/LineLength
gem.name = 'flipper-redis'
gem.require_paths = ['lib']
gem.version = Flipper::VERSION
Expand Down
4 changes: 2 additions & 2 deletions flipper-rollout.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Gem::Specification.new do |gem|
gem.license = 'MIT'
gem.homepage = 'https://github.com/jnunemaker/flipper'

gem.files = `git ls-files`.split("\n").select(&flipper_rollout_files) + ['lib/flipper/version.rb'] # rubocop:disable Metrics/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_rollout_files) # rubocop:disable Metrics/LineLength
gem.files = `git ls-files`.split("\n").select(&flipper_rollout_files) + ['lib/flipper/version.rb'] # rubocop:disable Layout/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_rollout_files) # rubocop:disable Layout/LineLength
gem.name = 'flipper-rollout'
gem.require_paths = ['lib']
gem.version = Flipper::VERSION
Expand Down
2 changes: 1 addition & 1 deletion flipper-sequel.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
'lib/flipper/version.rb',
]
gem.files = `git ls-files`.split("\n").select(&flipper_sequel_files) + extra_files
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_sequel_files) # rubocop:disable Metrics/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_sequel_files) # rubocop:disable Layout/LineLength
gem.name = 'flipper-sequel'
gem.require_paths = ['lib']
gem.version = Flipper::VERSION
Expand Down
4 changes: 2 additions & 2 deletions flipper-ui.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Gem::Specification.new do |gem|
gem.authors = ['John Nunemaker']
gem.email = ['[email protected]']
gem.summary = 'UI for the Flipper gem'
gem.description = 'Rack middleware that provides a fully featured web interface for the flipper gem.' # rubocop:disable Metrics/LineLength
gem.description = 'Rack middleware that provides a fully featured web interface for the flipper gem.' # rubocop:disable Layout/LineLength
gem.license = 'MIT'
gem.homepage = 'https://github.com/jnunemaker/flipper'

gem.files = `git ls-files`.split("\n").select(&flipper_ui_files) + ['lib/flipper/version.rb'] # rubocop:disable Metrics/LineLength
gem.files = `git ls-files`.split("\n").select(&flipper_ui_files) + ['lib/flipper/version.rb'] # rubocop:disable Layout/LineLength
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_ui_files)
gem.name = 'flipper-ui'
gem.require_paths = ['lib']
Expand Down
2 changes: 1 addition & 1 deletion flipper.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |gem|
gem.authors = ['John Nunemaker']
gem.email = ['[email protected]']
gem.summary = 'Feature flipper for ANYTHING'
gem.description = 'Feature flipper is the act of enabling/disabling features in your application, ideally without re-deploying or changing anything in your code base. Flipper makes this extremely easy to do with any backend you would like to use.' # rubocop:disable Metrics/LineLength
gem.description = 'Feature flipper is the act of enabling/disabling features in your application, ideally without re-deploying or changing anything in your code base. Flipper makes this extremely easy to do with any backend you would like to use.' # rubocop:disable Layout/LineLength
gem.homepage = 'https://github.com/jnunemaker/flipper'
gem.license = 'MIT'

Expand Down
43 changes: 17 additions & 26 deletions lib/flipper/adapters/sequel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 +121,9 @@ def get_all
def enable(feature, gate, thing)
case gate.data_type
when :boolean
@gate_class.db.transaction do
clear(feature)
args = {
feature_key: feature.key,
key: gate.key.to_s,
}
@gate_class.where(args).delete
@gate_class.create(gate_attrs(feature, gate, thing))
end
set(feature, gate, thing, clear: true)
when :integer
@gate_class.db.transaction do
args = {
feature_key: feature.key,
key: gate.key.to_s,
}
@gate_class.where(args).delete
@gate_class.create(gate_attrs(feature, gate, thing))
end
set(feature, gate, thing)
when :set
begin
@gate_class.create(gate_attrs(feature, gate, thing))
Expand All @@ -163,15 +148,7 @@ def disable(feature, gate, thing)
when :boolean
clear(feature)
when :integer
@gate_class.db.transaction do
args = {
feature_key: feature.key.to_s,
key: gate.key.to_s,
}
@gate_class.where(args).delete

@gate_class.create(gate_attrs(feature, gate, thing))
end
set(feature, gate, thing)
when :set
@gate_class.where(gate_attrs(feature, gate, thing))
.delete
Expand All @@ -188,6 +165,20 @@ def unsupported_data_type(data_type)
raise "#{data_type} is not supported by this adapter"
end

def set(feature, gate, thing, options = {})
clear_feature = options.fetch(:clear, false)
args = {
feature_key: feature.key,
key: gate.key.to_s,
}

@gate_class.db.transaction do
clear(feature) if clear_feature
@gate_class.where(args).delete
@gate_class.create(gate_attrs(feature, gate, thing))
end
end

def gate_attrs(feature, gate, thing)
{
feature_key: feature.key.to_s,
Expand Down
2 changes: 1 addition & 1 deletion lib/flipper/middleware/memoizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Memoizer
#
def initialize(app, opts = {})
if opts.is_a?(Flipper::DSL) || opts.is_a?(Proc)
raise 'Flipper::Middleware::Memoizer no longer initializes with a flipper instance or block. Read more at: https://git.io/vSo31.' # rubocop:disable LineLength
raise 'Flipper::Middleware::Memoizer no longer initializes with a flipper instance or block. Read more at: https://git.io/vSo31.' # rubocop:disable Layout/LineLength
end

@app = app
Expand Down
6 changes: 3 additions & 3 deletions lib/flipper/ui/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class Configuration
def initialize
@actors = Option.new("Actors", "Enable actors using the form above.")
@groups = Option.new("Groups", "Enable groups using the form above.")
@percentage_of_actors = Option.new("Percentage of Actors", "Percentage of actors functions independently of percentage of time. If you enable 50% of Actors and 25% of Time then the feature will always be enabled for 50% of users and occasionally enabled 25% of the time for everyone.") # rubocop:disable Metrics/LineLength
@percentage_of_time = Option.new("Percentage of Time", "Percentage of actors functions independently of percentage of time. If you enable 50% of Actors and 25% of Time then the feature will always be enabled for 50% of users and occasionally enabled 25% of the time for everyone.") # rubocop:disable Metrics/LineLength
@delete = Option.new("Danger Zone", "Deleting a feature removes it from the list of features and disables it for everyone.") # rubocop:disable Metrics/LineLength
@percentage_of_actors = Option.new("Percentage of Actors", "Percentage of actors functions independently of percentage of time. If you enable 50% of Actors and 25% of Time then the feature will always be enabled for 50% of users and occasionally enabled 25% of the time for everyone.") # rubocop:disable Layout/LineLength
@percentage_of_time = Option.new("Percentage of Time", "Percentage of actors functions independently of percentage of time. If you enable 50% of Actors and 25% of Time then the feature will always be enabled for 50% of users and occasionally enabled 25% of the time for everyone.") # rubocop:disable Layout/LineLength
@delete = Option.new("Danger Zone", "Deleting a feature removes it from the list of features and disables it for everyone.") # rubocop:disable Layout/LineLength
@banner_text = nil
@banner_class = 'danger'
@feature_creation_enabled = true
Expand Down
8 changes: 4 additions & 4 deletions spec/flipper/ui/actions/actors_gate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,23 @@
context 'empty value' do
let(:value) { '' }

# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
it 'redirects back to feature' do
expect(last_response.status).to be(302)
expect(last_response.headers['Location']).to eq('/features/search/actors?error=%22%22+is+not+a+valid+actor+value.')
end
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end

context 'nil value' do
let(:value) { nil }

# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
it 'redirects back to feature' do
expect(last_response.status).to be(302)
expect(last_response.headers['Location']).to eq('/features/search/actors?error=%22%22+is+not+a+valid+actor+value.')
end
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/flipper/ui/actions/features_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@
expect(flipper.features.map(&:key)).to eq([])
end

# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
it 'redirects back to feature' do
expect(last_response.status).to be(302)
expect(last_response.headers['Location']).to eq('/features/new?error=%22%22+is+not+a+valid+feature+name.')
end
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end

context 'nil feature name' do
Expand All @@ -126,12 +126,12 @@
expect(flipper.features.map(&:key)).to eq([])
end

# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
it 'redirects back to feature' do
expect(last_response.status).to be(302)
expect(last_response.headers['Location']).to eq('/features/new?error=%22%22+is+not+a+valid+feature+name.')
end
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/flipper/ui/actions/groups_gate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,34 @@
context 'unknown group name' do
let(:group_name) { 'not_here' }

# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
it 'redirects back to feature' do
expect(last_response.status).to be(302)
expect(last_response.headers['Location']).to eq('/features/search/groups?error=The+group+named+%22not_here%22+has+not+been+registered.')
end
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end

context 'empty group name' do
let(:group_name) { '' }

# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
it 'redirects back to feature' do
expect(last_response.status).to be(302)
expect(last_response.headers['Location']).to eq('/features/search/groups?error=The+group+named+%22%22+has+not+been+registered.')
end
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end

context 'nil group name' do
let(:group_name) { nil }

# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
it 'redirects back to feature' do
expect(last_response.status).to be(302)
expect(last_response.headers['Location']).to eq('/features/search/groups?error=The+group+named+%22%22+has+not+been+registered.')
end
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
end
end
end
Expand Down
Loading

0 comments on commit cae3f8c

Please sign in to comment.