govuk_app_config 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35f743a622acf54ffad6414762bb3af0ebfc230c40b19b8f57286671f3fe6211
4
- data.tar.gz: 4f39093e5358964cae3e587a4841c414b6f2eaf14381b25e6fa909f4a163bcc6
3
+ metadata.gz: 11f06b82c25ddd23f985b025b26abdcce2a1c4ab772cdbf129907962d8297da8
4
+ data.tar.gz: aa6e55ea958fd54cf9eb833762cbf3dfc24d310af1e3bf6dd8a010f3ad4d9bc9
5
5
  SHA512:
6
- metadata.gz: 7fedf54ca7d82cca175148e41fb0a72ca448675a8ccf3346bc5d29c47c7905786e3b0bfc2d0b3f4ffa0abaea786ff98e79b539df789207b1877a076182e7f913
7
- data.tar.gz: 6243b62c1b2e679c033525843d527c8fc7c2c6cd2b8ab7df3aa2d6a070dd4c527af32fbfdeeabc0e53e35be2383d21f002b1816e4a8e1ce372b84279029c11b0
6
+ metadata.gz: c5f01c3eb3f450616bc04577f788a36a4907d690d5694f9e813c89c985b370ad2b94abc53653a3a98885fed96799d7f34085e2e478d545ee15ac9421e846800d
7
+ data.tar.gz: cbe282314f027a01ed6fd1aae0e490b67b0fcb8425dc802dc7311bab8d97dea60f531b30302879fbe4a11d01f95bd61edda203dda1539c01831ec089d71db278
@@ -0,0 +1,3 @@
1
+ inherit_gem:
2
+ rubocop-govuk:
3
+ - config/default.yml
@@ -1,3 +1,7 @@
1
+ # 2.2.1
2
+
3
+ * Fix linting issues (https://github.com/alphagov/govuk_app_config/pull/149)
4
+
1
5
  # 2.2.0
2
6
 
3
7
  * Monkey patch `ActionDispatch::DebugExceptions#log_error` so it logs errors on a single line (https://github.com/alphagov/govuk_app_config/pull/147)
data/Rakefile CHANGED
@@ -3,4 +3,9 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ desc "Lint Ruby"
7
+ task :lint do
8
+ sh "bundle exec rubocop --format clang"
9
+ end
10
+
11
+ task default: %i[spec lint]
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  lib = File.expand_path("lib", __dir__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
  require "govuk_app_config/version"
@@ -29,10 +27,11 @@ Gem::Specification.new do |spec|
29
27
 
30
28
  spec.add_development_dependency "bundler", "~> 1.15"
31
29
  spec.add_development_dependency "climate_control"
32
- spec.add_development_dependency "rack-test", "~> 0.6.3"
30
+ spec.add_development_dependency "rack-test", "~> 1.1.0"
33
31
  spec.add_development_dependency "rails", "~> 6"
34
32
  spec.add_development_dependency "rake", "~> 13.0"
35
33
  spec.add_development_dependency "rspec", "~> 3.9.0"
36
34
  spec.add_development_dependency "rspec-its", "~> 1.3.0"
35
+ spec.add_development_dependency "rubocop-govuk"
37
36
  spec.add_development_dependency "webmock"
38
37
  end
@@ -1,5 +1,5 @@
1
1
  GovukError.configure do |config|
2
- config.before_send = Proc.new { |e|
2
+ config.before_send = proc { |e|
3
3
  GovukStatsd.increment("errors_occurred")
4
4
  GovukStatsd.increment("error_types.#{e.class.name.demodulize.underscore}")
5
5
  e
@@ -43,7 +43,7 @@ GovukError.configure do |config|
43
43
  # Rails will raise a ActionView::Template::Error, instead of the original error.
44
44
  config.inspect_exception_causes_for_exclusion = true
45
45
 
46
- config.transport_failure_callback = Proc.new {
46
+ config.transport_failure_callback = proc {
47
47
  GovukStatsd.increment("error_reports_failed")
48
48
  }
49
49
  end
@@ -9,15 +9,15 @@ module GovukContentSecurityPolicy
9
9
  # - https://cspvalidator.org
10
10
 
11
11
  GOVUK_DOMAINS = [
12
- '*.publishing.service.gov.uk',
12
+ "*.publishing.service.gov.uk",
13
13
  "*.#{ENV['GOVUK_APP_DOMAIN_EXTERNAL'] || ENV['GOVUK_APP_DOMAIN'] || 'dev.gov.uk'}",
14
14
  "www.gov.uk",
15
- "*.dev.gov.uk"
15
+ "*.dev.gov.uk",
16
16
  ].uniq.freeze
17
17
 
18
- GOOGLE_ANALYTICS_DOMAINS = %w(www.google-analytics.com
18
+ GOOGLE_ANALYTICS_DOMAINS = %w[www.google-analytics.com
19
19
  ssl.google-analytics.com
20
- stats.g.doubleclick.net).freeze
20
+ stats.g.doubleclick.net].freeze
21
21
 
22
22
  def self.build_policy(policy)
23
23
  # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/default-src
@@ -13,8 +13,8 @@ module GovukHealthcheck
13
13
  proc do
14
14
  [
15
15
  200,
16
- {"Content-Type" => "application/json"},
17
- [JSON.dump(healthcheck(checks))]
16
+ { "Content-Type" => "application/json" },
17
+ [JSON.dump(healthcheck(checks))],
18
18
  ]
19
19
  end
20
20
  end
@@ -7,7 +7,7 @@ module GovukHealthcheck
7
7
  def status
8
8
  ::ActiveRecord::Base.connection
9
9
  OK
10
- rescue StandardError => e
10
+ rescue StandardError
11
11
  CRITICAL
12
12
  end
13
13
  end
@@ -43,7 +43,7 @@ module GovukHealthcheck
43
43
  end
44
44
 
45
45
  def status?(status)
46
- component_statuses.values.any? {|s| s[:status] == status }
46
+ component_statuses.values.any? { |s| s[:status] == status }
47
47
  end
48
48
 
49
49
  def build_component_status(check)
@@ -41,7 +41,7 @@ module GovukHealthcheck
41
41
  thresholds: {
42
42
  critical: critical_threshold(queue: name),
43
43
  warning: warning_threshold(queue: name),
44
- }.select { |_, val| !(val.to_f.infinite? || val.to_f.nan?) },
44
+ }.reject { |_, val| val.to_f.infinite? || val.to_f.nan? },
45
45
  }
46
46
  end,
47
47
  }
@@ -51,11 +51,11 @@ module GovukHealthcheck
51
51
  raise "This method must be overriden to be a hash of queue names and data."
52
52
  end
53
53
 
54
- def critical_threshold(queue:)
54
+ def critical_threshold(queue:) # rubocop:disable Lint/UnusedMethodArgument
55
55
  raise "This method must be overriden to be the critical threshold."
56
56
  end
57
57
 
58
- def warning_threshold(queue:)
58
+ def warning_threshold(queue:) # rubocop:disable Lint/UnusedMethodArgument
59
59
  raise "This method must be overriden to be the warning threshold."
60
60
  end
61
61
  end
@@ -6,7 +6,6 @@ module GovukHealthcheck
6
6
 
7
7
  def status
8
8
  Sidekiq.redis_info ? OK : CRITICAL
9
-
10
9
  rescue StandardError
11
10
  # One would expect a Redis::BaseConnectionError, but this should be
12
11
  # critical if any exception is raised when making a call to redis.
@@ -1,6 +1,6 @@
1
- require 'logstasher'
2
- require 'action_controller'
3
- require_relative 'rails_ext/action_dispatch/debug_exceptions'
1
+ require "logstasher"
2
+ require "action_controller"
3
+ require_relative "rails_ext/action_dispatch/debug_exceptions"
4
4
 
5
5
  module GovukLogging
6
6
  def self.configure
@@ -14,8 +14,11 @@ module GovukLogging
14
14
  #
15
15
  # To resolve this we've directed stdout to stderr, to cover any Rails
16
16
  # writing. This frees up the normal stdout for the logstasher logs.
17
+
18
+ # rubocop:disable Style/GlobalVars
17
19
  $real_stdout = $stdout.clone
18
20
  $stdout.reopen($stderr)
21
+ # rubocop:enable Style/GlobalVars
19
22
 
20
23
  # Send Rails' logs to STDERR because they're not JSON formatted.
21
24
  Rails.logger = ActiveSupport::TaggedLogging.new(Logger.new($stderr, level: Rails.logger.level))
@@ -23,7 +26,7 @@ module GovukLogging
23
26
  # Custom that will be added to the Rails request logs
24
27
  LogStasher.add_custom_fields do |fields|
25
28
  # Mirrors Nginx request logging, e.g GET /path/here HTTP/1.1
26
- fields[:request] = "#{request.request_method} #{request.fullpath} #{request.headers["SERVER_PROTOCOL"]}"
29
+ fields[:request] = "#{request.request_method} #{request.fullpath} #{request.headers['SERVER_PROTOCOL']}"
27
30
 
28
31
  # Pass request Id to logging
29
32
  fields[:govuk_request_id] = request.headers["GOVUK-Request-Id"]
@@ -45,11 +48,11 @@ module GovukLogging
45
48
  Rails.application.config.logstasher.job_enabled = false
46
49
 
47
50
  Rails.application.config.logstasher.logger = Logger.new(
48
- $real_stdout,
51
+ $real_stdout, # rubocop:disable Style/GlobalVars
49
52
  level: Rails.logger.level,
50
53
  formatter: proc { |_severity, _datetime, _progname, msg|
51
- "#{String === msg ? msg : msg.inspect}\n"
52
- }
54
+ "#{msg.is_a?(String) ? msg : msg.inspect}\n"
55
+ },
53
56
  )
54
57
  Rails.application.config.logstasher.suppress_app_log = true
55
58
 
@@ -4,10 +4,10 @@ require "forwardable"
4
4
  module GovukStatsd
5
5
  extend SingleForwardable
6
6
  def_delegators :client, :increment, :decrement, :count, :time, :timing,
7
- :gauge, :set, :batch
7
+ :gauge, :set, :batch
8
8
 
9
9
  def self.client
10
- @statsd_client ||= begin
10
+ @client ||= begin
11
11
  statsd_client = ::Statsd.new("localhost")
12
12
  statsd_client.namespace = ENV["GOVUK_STATSD_PREFIX"].to_s
13
13
  statsd_client
@@ -9,8 +9,9 @@ module GovukUnicorn
9
9
  config.stderr_path "#{ENV['GOVUK_APP_LOGROOT']}/app.err.log"
10
10
  end
11
11
 
12
- config.before_exec do |server|
12
+ config.before_exec do |_server|
13
13
  next unless ENV["GOVUK_APP_ROOT"]
14
+
14
15
  ENV["BUNDLE_GEMFILE"] = "#{ENV['GOVUK_APP_ROOT']}/Gemfile"
15
16
  end
16
17
 
@@ -13,22 +13,21 @@ module GovukLogging
13
13
  should_monkey_patch = actual_parameters == expected_parameters
14
14
 
15
15
  unless should_monkey_patch
16
- Rails.logger.warn "Refused to monkey patch ::ActionDispatch::DebugExceptions#log_error - " +
17
- "signatures do not match. " +
16
+ Rails.logger.warn "Refused to monkey patch ::ActionDispatch::DebugExceptions#log_error - " \
17
+ "signatures do not match. " \
18
18
  "Expected #{expected_parameters}, but got #{actual_parameters}"
19
19
  end
20
20
 
21
21
  should_monkey_patch
22
-
23
- rescue StandardError => ex
24
- Rails.logger.warn "Failed to detect whether to monkey patch " +
25
- "::ActionDispatch::DebugExceptions#log_error - #{ex.inspect}"
22
+ rescue StandardError => e
23
+ Rails.logger.warn "Failed to detect whether to monkey patch " \
24
+ "::ActionDispatch::DebugExceptions#log_error - #{e.inspect}"
26
25
  false
27
26
  end
28
27
 
29
28
  def self.monkey_patch_log_error(clazz = ::ActionDispatch::DebugExceptions)
30
29
  clazz.class_eval do
31
- private
30
+ private
32
31
 
33
32
  def log_error(request, wrapper)
34
33
  logger = logger(request)
@@ -1,3 +1,3 @@
1
1
  module GovukAppConfig
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_app_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-15 00:00:00.000000000 Z
11
+ date: 2020-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstasher
@@ -118,14 +118,14 @@ dependencies:
118
118
  requirements:
119
119
  - - "~>"
120
120
  - !ruby/object:Gem::Version
121
- version: 0.6.3
121
+ version: 1.1.0
122
122
  type: :development
123
123
  prerelease: false
124
124
  version_requirements: !ruby/object:Gem::Requirement
125
125
  requirements:
126
126
  - - "~>"
127
127
  - !ruby/object:Gem::Version
128
- version: 0.6.3
128
+ version: 1.1.0
129
129
  - !ruby/object:Gem::Dependency
130
130
  name: rails
131
131
  requirement: !ruby/object:Gem::Requirement
@@ -182,6 +182,20 @@ dependencies:
182
182
  - - "~>"
183
183
  - !ruby/object:Gem::Version
184
184
  version: 1.3.0
185
+ - !ruby/object:Gem::Dependency
186
+ name: rubocop-govuk
187
+ requirement: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ type: :development
193
+ prerelease: false
194
+ version_requirements: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
185
199
  - !ruby/object:Gem::Dependency
186
200
  name: webmock
187
201
  requirement: !ruby/object:Gem::Requirement
@@ -205,6 +219,7 @@ extra_rdoc_files: []
205
219
  files:
206
220
  - ".gitignore"
207
221
  - ".rspec"
222
+ - ".rubocop.yml"
208
223
  - ".ruby-version"
209
224
  - CHANGELOG.md
210
225
  - Gemfile