Skip to content

Commit

Permalink
fix: Change appsignal info method based presence
Browse files Browse the repository at this point in the history
  • Loading branch information
KoenSengers committed Feb 2, 2024
1 parent 116e699 commit d05ff24
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ jobs:
fail-fast: false
matrix:
ruby:
- 3.0
- 3.1
- 3.2
- 3.3

runs-on: ubuntu-latest
steps:
Expand Down
16 changes: 16 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require:
- rubocop-performance

AllCops:
NewCops: enable
TargetRubyVersion: 3.1

Style/Documentation:
Enabled: false

Gemspec/DevelopmentDependencies:
Enabled: false

Naming/FileName:
Exclude:
- 'lib/appsignal-sourcemap.rb'
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"
source 'https://rubygems.org'

Check failure on line 3 in Gemfile

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] Gemfile#L3

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  Gemfile:3:8: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

gemspec
27 changes: 14 additions & 13 deletions appsignal-sourcemap.gemspec
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
# frozen_string_literal: true

$LOAD_PATH.push File.expand_path("lib", __dir__)
$LOAD_PATH.push File.expand_path('lib', __dir__)

Check failure on line 3 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L3

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:3:34: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

# Maintain your gem's version:
require "appsignal/sourcemap/version"
require 'appsignal/sourcemap/version'

Check failure on line 6 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L6

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:6:9: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

# Describe your gem and declare its dependencies:
Gem::Specification.new do |spec|
spec.name = "appsignal-sourcemap"
spec.name = 'appsignal-sourcemap'

Check failure on line 10 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L10

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:10:15: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
spec.version = Appsignal::Sourcemap::VERSION
spec.authors = ["Drieam"]
spec.email = ["[email protected]"]
spec.homepage = "https://github.com/drieam/appsignal-sourcemap"
spec.summary = "Upload private sourcemaps to appsignal"
spec.authors = ['Drieam']

Check failure on line 12 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L12

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:12:19: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
spec.email = ['[email protected]']

Check failure on line 13 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L13

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:13:17: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
spec.homepage = 'https://github.com/drieam/appsignal-sourcemap'

Check failure on line 14 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L14

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:14:19: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
spec.summary = 'Upload private sourcemaps to appsignal'

Check failure on line 15 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L15

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:15:18: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

spec.metadata["allowed_push_host"] = "https://rubygems.pkg.github.com/Drieam"
spec.metadata['allowed_push_host'] = 'https://rubygems.pkg.github.com/Drieam'

Check failure on line 17 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L17

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:17:17: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Check failure on line 17 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L17

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:17:40: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

spec.required_ruby_version = ">= 2.7"
spec.required_ruby_version = '>= 3.1'

Check failure on line 19 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L19

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:19:32: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

spec.files = Dir["lib/**/*", "README.md"]
spec.files = Dir['lib/**/*', 'README.md']

Check failure on line 21 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L21

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:21:20: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Check failure on line 21 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L21

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:21:32: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

spec.add_dependency "appsignal", "~> 3.0"
spec.add_dependency "parallel", "~> 1.0"
spec.add_dependency 'appsignal', '~> 3.0'

Check failure on line 23 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L23

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:23:23: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Check failure on line 23 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L23

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:23:36: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
spec.add_dependency 'parallel', '~> 1.0'

Check failure on line 24 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L24

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:24:23: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Check failure on line 24 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L24

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:24:35: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

spec.add_development_dependency "standard"
spec.add_development_dependency 'standard'

Check failure on line 26 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L26

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:26:35: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
spec.metadata['rubygems_mfa_required'] = 'true'

Check failure on line 27 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L27

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:27:17: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Check failure on line 27 in appsignal-sourcemap.gemspec

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] appsignal-sourcemap.gemspec#L27

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  appsignal-sourcemap.gemspec:27:44: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
end
2 changes: 1 addition & 1 deletion lib/appsignal-sourcemap.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frozen_string_literal: true

require "appsignal/sourcemap/hook"
require 'appsignal/sourcemap/hook'

Check failure on line 3 in lib/appsignal-sourcemap.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal-sourcemap.rb#L3

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal-sourcemap.rb:3:9: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
14 changes: 14 additions & 0 deletions lib/appsignal/sourcemap/base.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module Appsignal
module Sourcemap
class Base
private

def log_appsignal(message, type = 'info')

Check failure on line 8 in lib/appsignal/sourcemap/base.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/base.rb#L8

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/base.rb:8:41: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
log_method = Appsignal.respond_to?(:internal_logger) ? 'internal_logger' : 'logger'

Check failure on line 9 in lib/appsignal/sourcemap/base.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/base.rb#L9

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/base.rb:9:64: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Check failure on line 9 in lib/appsignal/sourcemap/base.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/base.rb#L9

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/base.rb:9:84: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Appsignal.send(log_method).send(type, message)
end
end
end
end
8 changes: 4 additions & 4 deletions lib/appsignal/sourcemap/hook.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require "appsignal/hooks"
require 'appsignal/hooks'

Check failure on line 3 in lib/appsignal/sourcemap/hook.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/hook.rb#L3

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/hook.rb:3:9: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

module Appsignal
module Sourcemap
Expand All @@ -10,15 +10,15 @@ class SourcemapHook < Appsignal::Hooks::Hook
def dependencies_present?
defined?(::Rails) &&
defined?(::Rake::Task) &&
Rake::Task.task_defined?("assets:precompile") &&
Rake::Task.task_defined?('assets:precompile') &&

Check failure on line 13 in lib/appsignal/sourcemap/hook.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/hook.rb#L13

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/hook.rb:13:36: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Appsignal.config &&
Appsignal.config[:upload_sourcemaps]
end

def install
require "appsignal/sourcemap/supervisor"
require 'appsignal/sourcemap/supervisor'

Check failure on line 19 in lib/appsignal/sourcemap/hook.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/hook.rb#L19

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/hook.rb:19:17: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Rake::Task["assets:precompile"].enhance do
Rake::Task['assets:precompile'].enhance do

Check failure on line 21 in lib/appsignal/sourcemap/hook.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/hook.rb#L21

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/hook.rb:21:20: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Appsignal::Sourcemap::Supervisor.start
end
end
Expand Down
20 changes: 9 additions & 11 deletions lib/appsignal/sourcemap/supervisor.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

require "parallel"
require "appsignal/sourcemap/uploader"
require 'parallel'

Check failure on line 3 in lib/appsignal/sourcemap/supervisor.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/supervisor.rb#L3

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/supervisor.rb:3:9: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
require 'appsignal/sourcemap/uploader'

Check failure on line 4 in lib/appsignal/sourcemap/supervisor.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/supervisor.rb#L4

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/supervisor.rb:4:9: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

module Appsignal
module Sourcemap
class Supervisor
class Supervisor < Base
PARALLEL_THREADS = 10

def self.start
Expand All @@ -15,27 +15,25 @@ def self.start
def start
return if invalid_preconditions

Appsignal.logger.info("Starting sourcemaps upload")
log_appsignal('Starting sourcemaps upload')

Check failure on line 18 in lib/appsignal/sourcemap/supervisor.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/supervisor.rb#L18

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/supervisor.rb:18:23: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Parallel.each(source_map_paths, in_threads: PARALLEL_THREADS) do |source_map_path|
Uploader.upload(source_map_path)
end

Appsignal.logger.info("Finished sourcemaps upload")
log_appsignal('Finished sourcemaps upload')

Check failure on line 24 in lib/appsignal/sourcemap/supervisor.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/supervisor.rb#L24

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/supervisor.rb:24:23: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
end

private

def invalid_preconditions
unless Appsignal.config.valid?
return Appsignal.logger.error("Skipping sourcemaps upload since Appsignal config is invalid")
return log_appsignal('Skipping sourcemaps upload since Appsignal config is invalid', 'error')

Check failure on line 31 in lib/appsignal/sourcemap/supervisor.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/supervisor.rb#L31

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/supervisor.rb:31:32: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Check failure on line 31 in lib/appsignal/sourcemap/supervisor.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/supervisor.rb#L31

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/supervisor.rb:31:96: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
end
if asset_host.blank?
return Appsignal.logger.error("Skipping sourcemaps upload since Rails asset_host is not set")
end
if source_map_paths.empty?
return Appsignal.logger.info("Skipping sourcemaps upload since no javascript maps are found")
return log_appsignal('Skipping sourcemaps upload since Rails asset_host is not set', 'error')

Check failure on line 34 in lib/appsignal/sourcemap/supervisor.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/supervisor.rb#L34

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/supervisor.rb:34:32: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Check failure on line 34 in lib/appsignal/sourcemap/supervisor.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/supervisor.rb#L34

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/supervisor.rb:34:96: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
end
return log_appsignal('Skipping sourcemaps upload since no javascript maps are found') if source_map_paths.empty?

Check failure on line 36 in lib/appsignal/sourcemap/supervisor.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/supervisor.rb#L36

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/supervisor.rb:36:30: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

false
end
Expand All @@ -45,7 +43,7 @@ def asset_host
end

def source_map_paths
Dir.glob("**/*.map", base: Rails.public_path)
Dir.glob('**/*.map', base: Rails.public_path)

Check failure on line 46 in lib/appsignal/sourcemap/supervisor.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/supervisor.rb#L46

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/supervisor.rb:46:18: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
end
end
end
Expand Down
37 changes: 21 additions & 16 deletions lib/appsignal/sourcemap/uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,63 @@

module Appsignal
module Sourcemap
class Uploader
UPLOAD_URI = URI("https://appsignal.com/api/sourcemaps")
class Uploader < Base
UPLOAD_URI = URI('https://appsignal.com/api/sourcemaps')

Check failure on line 6 in lib/appsignal/sourcemap/uploader.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/uploader.rb#L6

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/uploader.rb:6:24: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

def self.upload(sourcemap_path)
new(sourcemap_path).upload
end

def initialize(sourcemap_path)
@sourcemap_path = sourcemap_path
super
end

def upload # rubocop:disable Metrics/AbcSize
Appsignal.logger.debug "Starting sourcemap upload '#{@sourcemap_path}' with parameters: #{request_form_data}"
def upload
log_appsignal("Starting sourcemap upload '#{@sourcemap_path}' with parameters: #{request_form_data}", 'debug')

Check failure on line 18 in lib/appsignal/sourcemap/uploader.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/uploader.rb#L18

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/uploader.rb:18:111: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

response = Net::HTTP.start(UPLOAD_URI.hostname, UPLOAD_URI.port, use_ssl: true) do |http|
http.request(request)
end

if response.is_a?(Net::HTTPSuccess)
Appsignal.logger.debug("Finished sourcemap upload '#{@sourcemap_path}'")
log_appsignal("Finished sourcemap upload '#{@sourcemap_path}'", 'debug')

Check failure on line 25 in lib/appsignal/sourcemap/uploader.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/uploader.rb#L25

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/uploader.rb:25:75: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
File.delete(sourcemap_full_path)
return
end

Appsignal.logger.error <<~MESSAGE
log_appsignal(error_message(response), 'error')

Check failure on line 30 in lib/appsignal/sourcemap/uploader.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/uploader.rb#L30

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/uploader.rb:30:48: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
end

private

def error_message(response)
<<~MESSAGE
Uploading sourcemap #{@sourcemap_path} failed with message '#{response.message}'.
Response: #{response.body}
MESSAGE
end

private

def sourcemap_full_path
Rails.public_path.join(@sourcemap_path)
end

def request
Net::HTTP::Post.new(UPLOAD_URI).tap do |request|
request.set_form request_form_data, "multipart/form-data"
request.set_form request_form_data, 'multipart/form-data'

Check failure on line 50 in lib/appsignal/sourcemap/uploader.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/uploader.rb#L50

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/uploader.rb:50:47: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
end
end

def request_form_data
[
["push_api_key", Appsignal.config[:push_api_key]],
["app_name", Appsignal.config[:name]],
["revision", Appsignal.config[:revision]],
["environment", Appsignal.config.env],
["name[]", source_url],
["file", sourcemap_content]
['push_api_key', Appsignal.config[:push_api_key]],

Check failure on line 56 in lib/appsignal/sourcemap/uploader.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/uploader.rb#L56

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/uploader.rb:56:12: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
['app_name', Appsignal.config[:name]],

Check failure on line 57 in lib/appsignal/sourcemap/uploader.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/uploader.rb#L57

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/uploader.rb:57:12: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
['revision', Appsignal.config[:revision]],

Check failure on line 58 in lib/appsignal/sourcemap/uploader.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/uploader.rb#L58

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/uploader.rb:58:12: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
['environment', Appsignal.config.env],

Check failure on line 59 in lib/appsignal/sourcemap/uploader.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/uploader.rb#L59

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/uploader.rb:59:12: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
['name[]', source_url],

Check failure on line 60 in lib/appsignal/sourcemap/uploader.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/uploader.rb#L60

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/uploader.rb:60:12: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
['file', sourcemap_content]

Check failure on line 61 in lib/appsignal/sourcemap/uploader.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/uploader.rb#L61

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/uploader.rb:61:12: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
]
end

Expand All @@ -66,7 +71,7 @@ def source_url
end

def js_path
@sourcemap_path.delete_suffix(".map")
@sourcemap_path.delete_suffix('.map')

Check failure on line 74 in lib/appsignal/sourcemap/uploader.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/uploader.rb#L74

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/uploader.rb:74:39: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
end

def asset_host
Expand Down
2 changes: 1 addition & 1 deletion lib/appsignal/sourcemap/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Appsignal
module Sourcemap
VERSION = "1.0.0.develop"
VERSION = '1.0.0.develop'

Check failure on line 5 in lib/appsignal/sourcemap/version.rb

View workflow job for this annotation

GitHub Actions / standardrb

[standardrb] lib/appsignal/sourcemap/version.rb#L5

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Raw output
  lib/appsignal/sourcemap/version.rb:5:15: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
end
end

0 comments on commit d05ff24

Please sign in to comment.