Skip to content

Instantly share code, notes, and snippets.

@davidgoldcode
Created April 14, 2022 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidgoldcode/a2e61750b40d1f8e6fa7a7a4c054c1e0 to your computer and use it in GitHub Desktop.
Save davidgoldcode/a2e61750b40d1f8e6fa7a7a4c054c1e0 to your computer and use it in GitHub Desktop.
diff --git a/.rubocop.yml b/.rubocop.yml
index e6d9b809b1..7320073fe0 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -121,13 +121,80 @@ Style/ConditionalAssignment:
Enabled: false
Layout/ArrayAlignment:
- Enabled: false
+ Enabled: true
+ EnforcedStyle: with_first_element
+ StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#align-multiline-arrays
Layout/HashAlignment:
- Enabled: false
+ Enabled: true
+ EnforcedStyle: table
+ EnforcedColonStyle: table
+ EnforcedHashRocketStyle: table
+ EnforcedColonStyle: table
+ EnforcedLastArgumentHashStyle: always_inspect
+ SupportedLastArgumentHashStyles:
+ - always_inspect
+ - always_ignore
+ - ignore_implicit
+ - ignore_explicit
+
Layout/ParameterAlignment:
- EnforcedStyle: with_fixed_indentation
+ Enabled: true
+ Description: Align the parameters of a method call if they span more than one line.
+ StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-double-indent
+ EnforcedStyle: with_first_parameter
+ SupportedStyles:
+ - with_first_parameter
+ - with_fixed_indentation
+
+# Supports --auto-correct
+Layout/FirstArrayElementLineBreak:
+ Description: Checks for a line break before the first element in a multi-line array.
+ Enabled: true
+
+Layout/MultilineArrayBraceLayout:
+ Description: Checks that the closing brace in an array literal is symmetrical with
+ respect to the opening brace and the array elements.
+ Enabled: true
+
+Layout/MultilineHashBraceLayout:
+ Description: >-
+ Checks that the closing brace in a hash literal is
+ symmetrical with respect to the opening brace and the
+ hash elements.
+ Enabled: true
+
+Layout/MultilineMethodCallBraceLayout:
+ Description: >-
+ Checks that the closing brace in a method call is
+ symmetrical with respect to the opening brace and the
+ method arguments.
+ Enabled: true
+ EnforcedStyle: symmetrical
+
+Layout/FirstHashElementLineBreak:
+ Enabled: true
+
+Layout/MultilineHashKeyLineBreaks:
+ Enabled: true
+
+Layout/ClosingParenthesisIndentation:
+ Description: Checks the indentation of hanging closing parentheses.
+ Enabled: true
+
+# Use trailing commas, because there are safer in ruby.
+Layout/DotPosition:
+ Enabled: true
+ EnforcedStyle: trailing
+
+# Supports --auto-correct
+Layout/ElseAlignment:
+ Description: Align elses and elsifs correctly.
+ Enabled: true
+
+Layout/EmptyLineAfterMagicComment:
+ Enabled: true
Style/BarePercentLiterals:
EnforcedStyle: percent_q
@@ -157,6 +224,15 @@ Style/DoubleNegation:
Layout/FirstParameterIndentation:
EnforcedStyle: consistent
+# Supports --auto-correct
+Layout/FirstMethodParameterLineBreak:
+ Description: Checks for a line break before the first parameter in a multi-line method
+ parameter definition.
+ Enabled: true
+
+Layout/FirstMethodParameterLineBreak:
+ Enabled: true
+
Style/FormatString:
EnforcedStyle: percent
@@ -172,8 +248,24 @@ Style/HashSyntax:
Style/IfUnlessModifier:
Enabled: false
+Layout/FirstHashElementLineBreak:
+ Description: Checks for a line break before the first element in a multi-line hash.
+ Enabled: true
+
+# Supports --auto-correct
Layout/FirstHashElementIndentation:
+ Description: Checks the indentation of the first key in a hash literal.
+ Enabled: true
EnforcedStyle: consistent
+ SupportedStyles:
+ - special_inside_parentheses
+ - consistent
+
+# Supports --auto-correct
+Layout/LeadingCommentSpace:
+ Description: Comments should start with a space.
+ StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#hash-space
+ Enabled: true
Layout/MultilineOperationIndentation:
EnforcedStyle: indented
@@ -221,6 +313,32 @@ Style/SingleLineBlockParams:
Layout/SpaceInsideBlockBraces:
EnforcedStyleForEmptyBraces: space
+Layout/SpaceInsideArrayLiteralBrackets:
+ EnforcedStyle: no_space
+ SupportedStyles:
+ - space
+ - no_space
+ # 'compact' normally requires a space inside the brackets, with the exception
+ # that successive left brackets or right brackets are collapsed together
+ - compact
+ EnforcedStyleForEmptyBrackets: no_space
+ SupportedStylesForEmptyBrackets:
+ - space
+ - no_space
+ Enabled: true
+
+# Supports --auto-correct
+Layout/SpaceInsideHashLiteralBraces:
+ Description: Use spaces inside hash literal braces - or don't.
+ StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#spaces-operators
+ Enabled: true
+ EnforcedStyle: space
+ EnforcedStyleForEmptyBraces: no_space
+ SupportedStyles:
+ - space
+ - no_space
+
+
Style/StringLiterals:
Enabled: false
@@ -240,7 +358,10 @@ Style/WordArray:
Layout/EndAlignment:
EnforcedStyleAlignWith: variable
+# Supports --auto-correct
Layout/FirstArrayElementIndentation:
+ Description: Checks the indentation of the first element in an array literal.
+ Enabled: true
EnforcedStyle: consistent
RSpec/MultipleMemoizedHelpers:
diff --git a/app/services/feature_service.rb b/app/services/feature_service.rb
index c5b1f79212..e6ec6f90ca 100644
--- a/app/services/feature_service.rb
+++ b/app/services/feature_service.rb
@@ -4,7 +4,7 @@ class FeatureService
launchdarkly_sdk_key = Rails.application.config.launchdarkly_sdk_key
if launchdarkly_sdk_key.present?
logger.level = ::Logger::WARN
- config = LaunchDarkly::Config.new(logger: logger)
+ config = LaunchDarkly::Config.new(logger: logger, connect_timeout: 20.0)
self.launchdarkly_client = LaunchDarkly::LDClient.new(launchdarkly_sdk_key, config)
end
end
diff --git a/config/initializers/kafka.rb b/config/initializers/kafka.rb
index d1b6238d45..e48a0562f3 100644
--- a/config/initializers/kafka.rb
+++ b/config/initializers/kafka.rb
@@ -7,13 +7,17 @@ class KafkaQuietLogger
@logger = logger
end
- delegate :info, :info?, :warn, :warn?, :error, :error?, :fatal, :fatal?, to: :@logger
+ delegate :info?, :warn, :warn?, :error, :error?, :fatal, :fatal?, to: :@logger
def debug?
false
end
def debug(*args); end
+
+ def info(*args)
+ @logger.info(*args) unless args[0].is_a?(String) && (args[0].match?(/There are no partitions to fetch from/i) || args[0].match?(/Failed to fetch/i) || args[0].match?(/Could not connect to/i) || args[0].match?(/Failed to/i) || args[0].match?(/Discovered cluster metadata/i))
+ end
end
class KafkaConfiguration
@@ -104,7 +108,7 @@ class KafkaConfiguration
end
end
-config = KafkaConfiguration.new(Rails.application.config)
+config = KafkaConfiguration.new(Rails.application.config)
non_resque_rake_task = File.basename($PROGRAM_NAME) == "rake" && ARGV[1] != "resque:workers"
non_local = (Rails.env.staging? || Rails.env.production?)
disabled = non_resque_rake_task && non_local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment