diff --git a/.rubocop.yml b/.rubocop.yml index 0389228a3a7766324bd81f72fa45cc9d0a11363c..8ba02e50969a97c48d9e9d0d8ffacf50d0f37d96 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,7 @@ +inherit_from: .rubocop_todo.yml + AllCops: - TargetRubyVersion: 2.3 + TargetRubyVersion: 2.7 DisplayCopNames: true # Just use double quotes please @@ -20,15 +22,15 @@ Style/RaiseArgs: Style/FrozenStringLiteralComment: Enabled: false +# Commonly used screens these days easily fit more than 80 characters. +Layout/LineLength: + Max: 120 + Metrics/MethodLength: Max: 15 Metrics/AbcSize: Enabled: false -# Commonly used screens these days easily fit more than 80 characters. -Metrics/LineLength: - Max: 120 - Metrics/ClassLength: Max: 150 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000000000000000000000000000000000000..e47f11769c35623a0b3fe8bdf95c882f70a9ad44 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,64 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2021-01-11 12:24:03 UTC using RuboCop version 0.93.1. +# 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. + +# Offense count: 1 +# Configuration parameters: Include. +# Include: **/*.gemspec +Gemspec/RequiredRubyVersion: + Exclude: + - 'gitlab-exporter.gemspec' + +# Offense count: 3 +Lint/AmbiguousBlockAssociation: + Exclude: + - 'spec/git_spec.rb' + - 'spec/util_spec.rb' + +# Offense count: 2 +# Configuration parameters: MaximumRangeSize. +Lint/MissingCopEnableDirective: + Exclude: + - 'spec/database/ci_builds_spec.rb' + - 'spec/git_process_proper_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Lint/NonDeterministicRequireOrder: + Exclude: + - 'spec/spec_helper.rb' + +# Offense count: 16 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods. +# ExcludedMethods: refine +Metrics/BlockLength: + Max: 349 + +# Offense count: 1 +# Configuration parameters: IgnoredMethods. +Metrics/CyclomaticComplexity: + Max: 8 + +# Offense count: 1 +# Configuration parameters: IgnoredMethods. +Metrics/PerceivedComplexity: + Max: 9 + +# Offense count: 1 +# Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols. +# SupportedStyles: inline, group +Style/AccessModifierDeclarations: + Exclude: + - 'lib/gitlab_exporter/util.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: + Exclude: + - 'lib/gitlab_exporter/database/base.rb' diff --git a/Gemfile.lock b/Gemfile.lock index f0bfe4d436e1293ffe9067d377d6af26e5c6f890..0ada7ab15c8bf4515b313fb031829354e9dc5681 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,22 +13,24 @@ PATH GEM remote: https://rubygems.org/ specs: - ast (2.4.0) + ast (2.4.1) connection_pool (2.2.2) diff-lcs (1.3) mustermann (1.0.3) - parser (2.5.1.0) - ast (~> 2.4.0) + parallel (1.20.1) + parser (3.0.0.0) + ast (~> 2.4.1) pg (1.2.2) - powerpack (0.1.1) quantile (0.2.1) rack (2.0.7) rack-protection (2.0.7) rack - rainbow (2.1.0) + rainbow (3.0.0) redis (4.1.3) redis-namespace (1.6.0) redis (>= 3.0.4) + regexp_parser (2.0.3) + rexml (3.2.4) rspec (3.7.0) rspec-core (~> 3.7.0) rspec-expectations (~> 3.7.0) @@ -42,13 +44,18 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.7.0) rspec-support (3.7.1) - rubocop (0.42.0) - parser (>= 2.3.1.1, < 3.0) - powerpack (~> 0.1) - rainbow (>= 1.99.1, < 3.0) + rubocop (0.93.1) + parallel (~> 1.10) + parser (>= 2.7.1.5) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8) + rexml + rubocop-ast (>= 0.6.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.8.1) + unicode-display_width (>= 1.4.0, < 2.0) + rubocop-ast (1.4.0) + parser (>= 2.7.1.5) + ruby-progressbar (1.11.0) sidekiq (5.2.7) connection_pool (~> 2.2, >= 2.2.2) rack (>= 1.5.0) @@ -60,7 +67,7 @@ GEM rack-protection (= 2.0.7) tilt (~> 2.0) tilt (2.0.9) - unicode-display_width (1.6.0) + unicode-display_width (1.7.0) PLATFORMS ruby diff --git a/bin/gitlab-exporter b/bin/gitlab-exporter index c040f0a1155861b7d25bcc02db5f66c07e4c4db8..c5c1e821dd7f4512431c063d3e41c349cddee4cb 100755 --- a/bin/gitlab-exporter +++ b/bin/gitlab-exporter @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) +$LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "optparse" require "gitlab_exporter" diff --git a/gitlab-exporter.gemspec b/gitlab-exporter.gemspec index cb1f5ccd5b64970f1c317c9a7022997e2885fd6a..428ad54d3b5a5ca8c00576b836ff790fa4ebb8ca 100644 --- a/gitlab-exporter.gemspec +++ b/gitlab-exporter.gemspec @@ -1,4 +1,4 @@ -lib = File.expand_path("../lib", __FILE__) +lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "gitlab_exporter/version" @@ -20,13 +20,13 @@ Gem::Specification.new do |s| s.homepage = "http://gitlab.com" s.license = "MIT" + s.add_runtime_dependency "connection_pool", "~> 2.2.1" s.add_runtime_dependency "pg", "~> 1.1" - s.add_runtime_dependency "sinatra", "~> 2.0.4" s.add_runtime_dependency "quantile", "~> 0.2.0" - s.add_runtime_dependency "sidekiq", "~> 5.2.1" s.add_runtime_dependency "redis", "~> 4.1.2" s.add_runtime_dependency "redis-namespace", "~> 1.6.0" - s.add_runtime_dependency "connection_pool", "~> 2.2.1" + s.add_runtime_dependency "sidekiq", "~> 5.2.1" + s.add_runtime_dependency "sinatra", "~> 2.0.4" s.add_development_dependency "rspec", "~> 3.7.0" s.add_development_dependency "rspec-expectations", "~> 3.7.0" diff --git a/lib/gitlab_exporter/cli.rb b/lib/gitlab_exporter/cli.rb index 2118b5f6bf920c23e9cd984da8a0b15fd84b8943..5d3d2ca86430f4a7abfe2e94511f2595a58d35a0 100644 --- a/lib/gitlab_exporter/cli.rb +++ b/lib/gitlab_exporter/cli.rb @@ -19,8 +19,7 @@ module GitLab # Empty runner that will raise an InvalidCLICommand when executed to provide the usage # in the exception message class NullRunner - def initialize(args) - end + def initialize(args); end def run fail InvalidCLICommand.new("Usage: #{EXECUTABLE_NAME} [options] [arguments...]\n\n"\ diff --git a/lib/gitlab_exporter/database/base.rb b/lib/gitlab_exporter/database/base.rb index 7941130e133274595f3065d427778ddce26389a1..a62250c24251f64c67b805123652191d014c1d13 100644 --- a/lib/gitlab_exporter/database/base.rb +++ b/lib/gitlab_exporter/database/base.rb @@ -31,13 +31,11 @@ module GitLab def with_connection_pool connection_pool.with do |conn| - begin - yield conn - rescue PG::UnableToSend => e - @logger.warn "Error sending to the database: #{e}" if @logger - conn.reset - raise e - end + yield conn + rescue PG::UnableToSend => e + @logger.warn "Error sending to the database: #{e}" if @logger + conn.reset + raise e end rescue PG::Error => e @logger.error "Error connecting to the database: #{e}" if @logger diff --git a/lib/gitlab_exporter/database/bloat.rb b/lib/gitlab_exporter/database/bloat.rb index 0ddd1554b2ea0aa17e110b9fcf5fa49cbb880f31..b71b8d0d471434ec69782b95442cf8eec319b801 100644 --- a/lib/gitlab_exporter/database/bloat.rb +++ b/lib/gitlab_exporter/database/bloat.rb @@ -35,7 +35,7 @@ module GitLab # Prober class to gather bloat metrics class BloatProber - METRIC_KEYS = %w(bloat_ratio bloat_size extra_size real_size).freeze + METRIC_KEYS = %w[bloat_ratio bloat_size extra_size real_size].freeze attr_reader :metrics, :collector, :bloat_types @@ -46,7 +46,7 @@ module GitLab @metrics = metrics @collector = collector @collector.logger = logger - @bloat_types = opts[:bloat_types] || %i(btree table) + @bloat_types = opts[:bloat_types] || %i[btree table] end def probe_db diff --git a/lib/gitlab_exporter/database/ci_builds.rb b/lib/gitlab_exporter/database/ci_builds.rb index 6b6bcf8564ab77eb3592898aff8a59b12fbbfaef..0aad624d43ba60f9938c20358fdb028ea6926d06 100644 --- a/lib/gitlab_exporter/database/ci_builds.rb +++ b/lib/gitlab_exporter/database/ci_builds.rb @@ -391,6 +391,7 @@ module GitLab def include_bool_if_row_defined(row, field) return {} unless row[field.to_s] + { field => row[field.to_s] == "t" ? "yes" : "no" } end @@ -470,7 +471,7 @@ module GitLab def add_ci_created_pending_builds(metric_name, value, labels) add_metric_with_namespace_label(metric_name, - [:namespace, :shared_runners, :has_minutes], + %i[namespace shared_runners has_minutes], value, labels) end @@ -505,8 +506,8 @@ module GitLab def add_ci_running_builds(value, labels) add_metric_with_namespace_label( "ci_running_builds", - [:runner, :namespace, :runner_type, :scheduled, - :triggered, :mirror, :mirror_trigger_builds, :has_minutes], + %i[runner namespace runner_type scheduled + triggered mirror mirror_trigger_builds has_minutes], value, labels ) diff --git a/lib/gitlab_exporter/database/row_count.rb b/lib/gitlab_exporter/database/row_count.rb index ecc0d6ee65054e02999c4aa9d8ebb4eeb88c87f2..baf9f9d772ff6bb1614e0460a2945410b3f04211 100644 --- a/lib/gitlab_exporter/database/row_count.rb +++ b/lib/gitlab_exporter/database/row_count.rb @@ -29,7 +29,7 @@ module GitLab MIRROR_QUERY = { select: :projects, - joins: <<~SQL, + joins: <<~SQL, INNER JOIN project_mirror_data ON project_mirror_data.project_id = projects.id INNER JOIN namespaces AS root_namespaces ON root_namespaces.id = ( WITH RECURSIVE "base_and_ancestors" AS ( @@ -112,9 +112,9 @@ module GitLab ON users.id = u.user_id", where: "user_type IS NULL", fields: { - admin: {}, - external: {}, - state: {}, + admin: {}, + external: {}, + state: {}, access_level: { definition: "COALESCE(u.access_level, 0)" } } }, @@ -122,14 +122,14 @@ module GitLab select: :projects, fields: { visibility_level: {}, - archived: {} + archived: {} } }, groups: { select: :namespaces, fields: { visibility_level: {}, - root: { definition: "(parent_id IS NULL)" } + root: { definition: "(parent_id IS NULL)" } } } }.freeze diff --git a/lib/gitlab_exporter/database/tuple_stats.rb b/lib/gitlab_exporter/database/tuple_stats.rb index 23bea9dcd8c4f573520c79de09b2efd82086edd7..a0a743cf18ee6d085900354de871e7dad0049f1e 100644 --- a/lib/gitlab_exporter/database/tuple_stats.rb +++ b/lib/gitlab_exporter/database/tuple_stats.rb @@ -5,7 +5,7 @@ module GitLab # # It takes a connection string (e.g. "dbname=test port=5432") class TupleStatsCollector < Base - COLUMNS = %w(relname seq_tup_read idx_tup_fetch n_tup_ins n_tup_upd n_tup_del n_tup_hot_upd n_dead_tup seq_scan) + COLUMNS = %w[relname seq_tup_read idx_tup_fetch n_tup_ins n_tup_upd n_tup_del n_tup_hot_upd n_dead_tup seq_scan] .join(",") QUERY = <<-SQL.freeze SELECT #{COLUMNS} @@ -35,9 +35,11 @@ module GitLab result.each do |table_name, tuple_stats| tuple_stats.each do |column_name, value| + next if value.is_a?(Numeric) + @metrics.add("gitlab_database_stat_table_#{column_name}", value.to_f, - table_name: table_name) unless value.is_a?(Numeric) + table_name: table_name) end end diff --git a/lib/gitlab_exporter/git.rb b/lib/gitlab_exporter/git.rb index 1da0f1c56a811aa54d21ced728afceecc985d5f0..98543e2d41a845880ec3e286b68ea7ea49558c06 100644 --- a/lib/gitlab_exporter/git.rb +++ b/lib/gitlab_exporter/git.rb @@ -13,6 +13,7 @@ module GitLab class Git def initialize(repo) fail "Repository #{repo} does not exists" unless Dir.exist? repo + @repo = repo @tracker = TimeTracker.new end @@ -35,6 +36,7 @@ module GitLab def execute(command) result = CommandResult.new(*Open3.capture2e(command, chdir: @repo)) fail "Command #{command} failed with status #{result.status}\n#{result.stdout}" if result.failed? + result end end @@ -96,7 +98,7 @@ module GitLab Utils.pgrep("^git ").each do |pid| process_cmd = begin File.read("/proc/#{pid}/cmdline") - rescue + rescue StandardError "" # Process file is gone (race condition) end subcommand = self.class.extract_subcommand(process_cmd) @@ -131,6 +133,7 @@ module GitLab def self.extract_subcommand(cmd) return if cmd.empty? + cmd_splitted = cmd.split("\u0000") # cmdline does not return it space-separated cmd_splitted.shift # Because it's "git" diff --git a/lib/gitlab_exporter/memstats.rb b/lib/gitlab_exporter/memstats.rb index 4dd530c5ff94e12ac2e1e021c806a5ccef070d1f..9c4748f8faa269b9100395e363be9c6169792fec 100644 --- a/lib/gitlab_exporter/memstats.rb +++ b/lib/gitlab_exporter/memstats.rb @@ -87,7 +87,7 @@ module GitLab end end end - rescue => e + rescue StandardError => e puts "Error: #{e}" @valid = false create_memstats_not_available(totals) diff --git a/lib/gitlab_exporter/memstats/mapping.rb b/lib/gitlab_exporter/memstats/mapping.rb index 8288863e25c254de06b899600dde3a9b941927be..1056c1e100e0c835c02d6e8494cebf68ea713f55 100644 --- a/lib/gitlab_exporter/memstats/mapping.rb +++ b/lib/gitlab_exporter/memstats/mapping.rb @@ -25,7 +25,7 @@ module GitLab # Locked: 0 kB # VmFlags: rd ex mr mw me dw sd class Mapping - FIELDS = %w(size rss shared_clean shared_dirty private_clean private_dirty swap pss).freeze + FIELDS = %w[size rss shared_clean shared_dirty private_clean private_dirty swap pss].freeze attr_reader :address_start attr_reader :address_end diff --git a/lib/gitlab_exporter/process.rb b/lib/gitlab_exporter/process.rb index 1c08cffd42058977e231411284dff48da9476565..876e7f728069021e98e3bd2439c6178319d81004 100644 --- a/lib/gitlab_exporter/process.rb +++ b/lib/gitlab_exporter/process.rb @@ -105,9 +105,7 @@ module GitLab ::GitLab::Exporter::MemStats::Mapping::FIELDS.each do |field| value = stats.totals[field] - if value >= 0 - @metrics.add("process_smaps_#{field}_bytes", value * 1024, @use_quantiles, **labels) - end + @metrics.add("process_smaps_#{field}_bytes", value * 1024, @use_quantiles, **labels) if value >= 0 end end diff --git a/lib/gitlab_exporter/sidekiq.rb b/lib/gitlab_exporter/sidekiq.rb index ec2d72f2d450d8aa64828751f2756cb1ea6c1ca8..efa9664185d67e9aa21575b12fec766963539e29 100644 --- a/lib/gitlab_exporter/sidekiq.rb +++ b/lib/gitlab_exporter/sidekiq.rb @@ -53,21 +53,19 @@ module GitLab self end - def probe_jobs # rubocop:disable Metrics/MethodLength + def probe_jobs return self unless connected? job_stats = {} Sidekiq::Queue.all.each do |queue| - begin - Sidekiq.redis do |conn| - stats = conn.evalsha(QUEUE_JOB_STATS_SHA, ["queue:#{queue.name}"]) - job_stats.merge!(stats.to_h) - end - rescue Redis::CommandError # Could happen if the script exceeded the maximum run time (5 seconds by default) - # FIXME: Should we call SCRIPT KILL? - return self + Sidekiq.redis do |conn| + stats = conn.evalsha(QUEUE_JOB_STATS_SHA, ["queue:#{queue.name}"]) + job_stats.merge!(stats.to_h) end + rescue Redis::CommandError # Could happen if the script exceeded the maximum run time (5 seconds by default) + # FIXME: Should we call SCRIPT KILL? + return self end job_stats.each do |class_name, count| @@ -153,7 +151,7 @@ module GitLab end true end - rescue Redis::CannotConnectError, Redis::TimeoutError # rubocop:disable Lint/HandleExceptions + rescue Redis::CannotConnectError, Redis::TimeoutError # Maybe we're trying connecting to a slave end @@ -164,6 +162,7 @@ module GitLab # Using administrative commands on conn directly (which is a Redis::Namespace) # will be removed in redis-namespace 2.0. next if conn.redis.script(:exists, QUEUE_JOB_STATS_SHA) + conn.redis.script(:load, QUEUE_JOB_STATS_SCRIPT) end end diff --git a/lib/gitlab_exporter/util.rb b/lib/gitlab_exporter/util.rb index a8b23616474d570a03db59cde6a515648cc0cdb4..22f9311ce99bab3410a178943b422fe4e42b3f36 100644 --- a/lib/gitlab_exporter/util.rb +++ b/lib/gitlab_exporter/util.rb @@ -24,7 +24,7 @@ module GitLab # Helper methods, some stuff was copied from ActiveSupport module Utils def camel_case_string(str) - str.gsub(/(?:_|^)([a-z\d]*)/i) { $1.capitalize } # rubocop:disable PerlBackrefs + str.gsub(/(?:_|^)([a-z\d]*)/i) { $1.capitalize } # rubocop:disable Style/PerlBackrefs end module_function :camel_case_string diff --git a/lib/gitlab_exporter/web_exporter.rb b/lib/gitlab_exporter/web_exporter.rb index be9e0a481020eadcd7b0e285416a26f4551b0f10..d464bba6aa860f10d77f9dc13bce77e0b8b72523 100644 --- a/lib/gitlab_exporter/web_exporter.rb +++ b/lib/gitlab_exporter/web_exporter.rb @@ -24,7 +24,7 @@ module GitLab private def memory_usage - io = IO.popen(%W(ps -o rss= -p #{$PID})) + io = IO.popen(%W[ps -o rss= -p #{$PID}]) mem = io.read io.close diff --git a/spec/database/bloat_spec.rb b/spec/database/bloat_spec.rb index 2a244f478b7fe388580aefb8a3c95d2953c5f0d9..f4745ec653acbab938bd36b70d73aea7b2ab2726 100644 --- a/spec/database/bloat_spec.rb +++ b/spec/database/bloat_spec.rb @@ -26,7 +26,7 @@ describe GitLab::Exporter::Database::BloatCollector do end describe GitLab::Exporter::Database::BloatProber do - let(:opts) { { bloat_types: %i(btree table) } } + let(:opts) { { bloat_types: %i[btree table] } } let(:metrics) { double("PrometheusMetrics", add: nil) } let(:collector) { double("BloatCollector", run: data) } diff --git a/spec/database/ci_builds_spec.rb b/spec/database/ci_builds_spec.rb index 854e8275c62585dcf477d86c531e69dad35300ba..704aabb83ac7756fd77ee32b0dbde894c53ffc8e 100644 --- a/spec/database/ci_builds_spec.rb +++ b/spec/database/ci_builds_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" require "gitlab_exporter/database/ci_builds" -# rubocop:disable Metrics/LineLength +# rubocop:disable Layout/LineLength describe GitLab::Exporter::Database do let(:set_random_page_cost_query) { "SET random_page_cost" } let(:builds_query_ee) { "SELECT BUILDS EE" } @@ -100,35 +100,35 @@ describe GitLab::Exporter::Database do allow(Time).to receive(:now).and_return(time_now) allow(connection).to receive(:exec).with(builds_query_ee) - .and_return([builds_query_row_ee("f", "created", "1", "f", 10), - builds_query_row_ee("t", "pending", "1", "t", 30), - builds_query_row_ee("f", "created", "2", "f", 20), - builds_query_row_ee("t", "pending", "2", "t", 50), - builds_query_row_ee("t", "pending", "3", "f", 1), - builds_query_row_ee("t", "pending", "4", "t", 2), - builds_query_row_ee("f", "pending", "5", "f", 2)]) + .and_return([builds_query_row_ee("f", "created", "1", "f", 10), + builds_query_row_ee("t", "pending", "1", "t", 30), + builds_query_row_ee("f", "created", "2", "f", 20), + builds_query_row_ee("t", "pending", "2", "t", 50), + builds_query_row_ee("t", "pending", "3", "f", 1), + builds_query_row_ee("t", "pending", "4", "t", 2), + builds_query_row_ee("f", "pending", "5", "f", 2)]) allow(connection).to receive(:exec).with(builds_query_ce) - .and_return([builds_query_row_ce("f", "created", "1", 10), - builds_query_row_ce("t", "pending", "1", 30), - builds_query_row_ce("f", "created", "2", 20), - builds_query_row_ce("t", "pending", "2", 50), - builds_query_row_ce("t", "pending", "3", 1), - builds_query_row_ce("t", "pending", "4", 2), - builds_query_row_ce("f", "pending", "5", 2)]) + .and_return([builds_query_row_ce("f", "created", "1", 10), + builds_query_row_ce("t", "pending", "1", 30), + builds_query_row_ce("f", "created", "2", 20), + builds_query_row_ce("t", "pending", "2", 50), + builds_query_row_ce("t", "pending", "3", 1), + builds_query_row_ce("t", "pending", "4", 2), + builds_query_row_ce("f", "pending", "5", 2)]) allow(connection).to receive(:exec).with(stale_builds_query).and_return([{ "count" => 2 }]) allow(connection).to receive(:exec).with(per_runner_query_ee) - .and_return([per_runner_query_row_ee(1, "instance_type", 1, "f", "f", 1, nil, "t", 15), - per_runner_query_row_ee(2, "project_type", 2, "t", "t", nil, 3, "f", 5), - per_runner_query_row_ee(2, "project_type", 3, "t", "t", nil, 3, "t", 5), - per_runner_query_row_ee(3, "project_type", 4, "t", "t", nil, 3, "f", 5)]) + .and_return([per_runner_query_row_ee(1, "instance_type", 1, "f", "f", 1, nil, "t", 15), + per_runner_query_row_ee(2, "project_type", 2, "t", "t", nil, 3, "f", 5), + per_runner_query_row_ee(2, "project_type", 3, "t", "t", nil, 3, "t", 5), + per_runner_query_row_ee(3, "project_type", 4, "t", "t", nil, 3, "f", 5)]) allow(connection).to receive(:exec).with(per_runner_query_ce) - .and_return([per_runner_query_row_ce(1, "instance_type", 1, 1, nil, 15), - per_runner_query_row_ce(2, "project_type", 2, nil, 3, 5), - per_runner_query_row_ce(2, "project_type", 3, nil, 3, 5), - per_runner_query_row_ce(3, "project_type", 4, nil, 3, 5)]) + .and_return([per_runner_query_row_ce(1, "instance_type", 1, 1, nil, 15), + per_runner_query_row_ce(2, "project_type", 2, nil, 3, 5), + per_runner_query_row_ce(2, "project_type", 3, nil, 3, 5), + per_runner_query_row_ce(3, "project_type", 4, nil, 3, 5)]) # rubocop:disable Style/FormatString repeated_commands_query_ee_with_limit = repeated_commands_query_ee % [allowed_repeated_commands_count] diff --git a/spec/git_process_proper_spec.rb b/spec/git_process_proper_spec.rb index 574cd4fb4549e858a3c31eb6561361be0c463781..ab7607706fb2389bfdb1f423c2693ae6fd0d815c 100644 --- a/spec/git_process_proper_spec.rb +++ b/spec/git_process_proper_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" require "gitlab_exporter" -# rubocop:disable Metrics/LineLength +# rubocop:disable Layout/LineLength describe GitLab::Exporter::GitProcessProber do describe ".extract_subcommand" do it "extract git subcommand" do diff --git a/spec/memstats_spec.rb b/spec/memstats_spec.rb index 359b792d1a86626fee22ef030951e472cac82e09..8e62ff49efba25d404f2d907eb5c5641564dcc3c 100644 --- a/spec/memstats_spec.rb +++ b/spec/memstats_spec.rb @@ -14,11 +14,11 @@ describe GitLab::Exporter::MemStats do it "parses the data properly" do expect(subject.valid?).to be_truthy - nonzero_fields = %w(size rss shared_clean shared_dirty private_dirty pss) - zero_fields = %w(private_clean swap) + nonzero_fields = %w[size rss shared_clean shared_dirty private_dirty pss] + zero_fields = %w[private_clean swap] nonzero_fields.each do |field| - expect(subject.totals[field]).to be > 0 # rubocop:disable Style/NumericPredicate + expect(subject.totals[field]).to be > 0 end zero_fields.each do |field| diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4e061d0fb08a2f4bde086921f94943cbb0ae098b..3b0c7c6fc6947fb146b82b58fd448ea6878e8b53 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -51,11 +51,9 @@ class CLIArgs yield self end - def on(*args) - end + def on(*args); end - def banner=(banner) - end + def banner=(banner); end def parse! @arguments