From edd9e93a7440f4e0edbacbc836c5148f04a0e941 Mon Sep 17 00:00:00 2001 From: Gleb Sinyavskiy Date: Mon, 20 Feb 2023 18:29:01 +0100 Subject: [PATCH 1/3] Update dependencies, drop unsupported ruby versions, create rubocop todo Signed-off-by: Gleb Sinyavskiy --- .rubocop.yml | 14 +++- .rubocop_todo.yml | 114 ++++++++++++++++++++++++++++ .travis.yml | 9 +-- Gemfile | 7 +- lib/prometheus/api_client/client.rb | 5 +- prometheus-api-client.gemspec | 23 +++--- 6 files changed, 146 insertions(+), 26 deletions(-) create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml index 616ec70..ee6757d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,14 +1,22 @@ +inherit_from: .rubocop_todo.yml + AllCops: + TargetRubyVersion: 3.0 Exclude: - lib/prometheus/api_client/version.rb + NewCops: disable + SuggestExtensions: false -AlignHash: +Layout/HashAlignment: EnforcedHashRocketStyle: table Style/TrailingCommaInArguments: EnforcedStyleForMultiline: comma -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: + EnforcedStyleForMultiline: comma + +Style/TrailingCommaInHashLiteral: EnforcedStyleForMultiline: comma Metrics/AbcSize: @@ -21,6 +29,6 @@ Metrics/BlockLength: Exclude: - 'spec/**/*.rb' -Metrics/LineLength: +Layout/LineLength: Exclude: - 'spec/**/*.rb' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..6838d84 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,114 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-02-20 17:21:35 UTC using RuboCop version 1.45.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: Severity, Include. +# Include: **/*.gemspec +Gemspec/RequiredRubyVersion: + Exclude: + - 'prometheus-api-client.gemspec' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Layout/EmptyLineAfterMagicComment: + Exclude: + - 'prometheus-api-client.gemspec' + +# Offense count: 8 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: + Exclude: + - 'examples/get_metrics.rb' + - 'examples/low_level.rb' + - 'spec/prometheus/api_client/client_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: PreferredName. +Naming/RescuedExceptionsVariableName: + Exclude: + - 'lib/prometheus/api_client/client.rb' + +# Offense count: 8 +# This cop supports safe autocorrection (--autocorrect). +Style/Encoding: + Exclude: + - 'Rakefile' + - 'lib/prometheus.rb' + - 'lib/prometheus/api_client.rb' + - 'lib/prometheus/api_client/client.rb' + - 'prometheus-api-client.gemspec' + - 'spec/prometheus/api_client/client_spec.rb' + - 'spec/prometheus/api_client_spec.rb' + - 'spec/spec_helper.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/ExpandPathArguments: + Exclude: + - 'prometheus-api-client.gemspec' + +# Offense count: 13 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Exclude: + - 'Gemfile' + - 'Rakefile' + - 'examples/authentication_proxy.rb' + - 'examples/get_labels.rb' + - 'examples/get_metrics.rb' + - 'examples/low_level.rb' + - 'lib/prometheus.rb' + - 'lib/prometheus/api_client.rb' + - 'lib/prometheus/api_client/client.rb' + - 'prometheus-api-client.gemspec' + - 'spec/prometheus/api_client/client_spec.rb' + - 'spec/prometheus/api_client_spec.rb' + - 'spec/spec_helper.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +# SupportedShorthandSyntax: always, never, either, consistent +Style/HashSyntax: + Exclude: + - 'spec/prometheus/api_client/client_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'prometheus-api-client.gemspec' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantCondition: + Exclude: + - 'lib/prometheus/api_client/client.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Mode. +Style/StringConcatenation: + Exclude: + - 'lib/prometheus/api_client/client.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MinSize. +# SupportedStyles: percent, brackets +Style/SymbolArray: + EnforcedStyle: brackets diff --git a/.travis.yml b/.travis.yml index fb3e30a..15a47ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,7 @@ before_install: - | if [[ "$(ruby -e 'puts RUBY_VERSION')" != 1.* ]]; then gem update --system; fi rvm: - - 2.3.3 - - 2.4.0 - - 2.5.3 - - 2.6.0 - - jruby-9.1.9.0 + - 3.0.5 + - 3.1.3 + - 3.2.1 + - jruby-9.4.1.0 diff --git a/Gemfile b/Gemfile index 57dcb92..7e3113b 100644 --- a/Gemfile +++ b/Gemfile @@ -10,14 +10,9 @@ gem 'faraday' group :test do gem 'coveralls' - gem 'json', '< 2.0' if ruby_version?('< 2.0') - gem 'rack', '< 2.0' if ruby_version?('< 2.2.2') - gem 'rack-test' gem 'rake' gem 'rspec' - gem 'rubocop', '< 0.42' - gem 'term-ansicolor', '< 1.4' if ruby_version?('< 2.0') - gem 'tins', '< 1.7' if ruby_version?('< 2.0') + gem 'rubocop' gem 'vcr' gem 'webmock' end diff --git a/lib/prometheus/api_client/client.rb b/lib/prometheus/api_client/client.rb index 7098598..bf78fa6 100644 --- a/lib/prometheus/api_client/client.rb +++ b/lib/prometheus/api_client/client.rb @@ -2,6 +2,7 @@ require 'json' require 'faraday' +require 'faraday/net_http' module Prometheus # Client is a ruby implementation for a Prometheus compatible api_client. @@ -38,7 +39,9 @@ def initialize(options = {}) @client = Faraday.new( faraday_options(options), - ) + ) do |f| + f.adapter :net_http + end end # Evaluates an instant query at a single point in time: diff --git a/prometheus-api-client.gemspec b/prometheus-api-client.gemspec index 7658d25..fbbddd1 100644 --- a/prometheus-api-client.gemspec +++ b/prometheus-api-client.gemspec @@ -3,17 +3,18 @@ $LOAD_PATH.push File.expand_path('../lib', __FILE__) require 'prometheus/api_client/version' Gem::Specification.new do |s| - s.name = 'prometheus-api-client' - s.version = Prometheus::ApiClient::VERSION - s.summary = 'A suite of reading metrics stored on ' \ - 'a Prometheus server.' - s.authors = ['Yaacov Zamir'] - s.email = ['kobi.zamir@gmail.com'] - s.homepage = 'https://github.com/yaacov/prometheus_api_client_ruby' - s.license = 'Apache-2.0' + s.name = 'prometheus-api-client' + s.version = Prometheus::ApiClient::VERSION + s.summary = 'A suite of reading metrics stored on ' \ + 'a Prometheus server.' + s.authors = ['Yaacov Zamir'] + s.email = ['kobi.zamir@gmail.com'] + s.homepage = 'https://github.com/yaacov/prometheus_api_client_ruby' + s.license = 'Apache-2.0' + s.required_ruby_version = '>= 3.0.0' - s.files = %w(README.md) + Dir.glob('{lib/**/*}') - s.require_paths = ['lib'] + s.files = %w(README.md) + Dir.glob('{lib/**/*}') + s.require_paths = ['lib'] - s.add_dependency 'faraday', '>= 0.9', '< 2.0.0' + s.add_dependency 'faraday', '>= 2.0.0', '< 3.0.0' end From a44fa2c4f102a63c46dfaf348845a055e769d539 Mon Sep 17 00:00:00 2001 From: Gleb Sinyavskiy Date: Mon, 20 Feb 2023 18:32:57 +0100 Subject: [PATCH 2/3] remove ruby_version? from Gemfile Signed-off-by: Gleb Sinyavskiy --- Gemfile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Gemfile b/Gemfile index 7e3113b..3367f40 100644 --- a/Gemfile +++ b/Gemfile @@ -2,10 +2,6 @@ source 'https://rubygems.org' gemspec -def ruby_version?(constraint) - Gem::Dependency.new('', constraint).match?('', RUBY_VERSION) -end - gem 'faraday' group :test do From 25af93846fdf92c552929c83c9582f079ded778f Mon Sep 17 00:00:00 2001 From: Gleb Sinyavskiy Date: Mon, 20 Feb 2023 18:39:44 +0100 Subject: [PATCH 3/3] Update rubocop todo Signed-off-by: Gleb Sinyavskiy --- .rubocop_todo.yml | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6838d84..ae06d02 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,18 +1,11 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-02-20 17:21:35 UTC using RuboCop version 1.45.1. +# on 2023-02-20 17:39:35 UTC using RuboCop version 1.45.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: Severity, Include. -# Include: **/*.gemspec -Gemspec/RequiredRubyVersion: - Exclude: - - 'prometheus-api-client.gemspec' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Layout/EmptyLineAfterMagicComment: @@ -77,15 +70,6 @@ Style/FrozenStringLiteralComment: - 'spec/prometheus/api_client_spec.rb' - 'spec/spec_helper.rb' -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -# SupportedShorthandSyntax: always, never, either, consistent -Style/HashSyntax: - Exclude: - - 'spec/prometheus/api_client/client_spec.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: PreferredDelimiters.