Fix up a bunch of Rubocop warnings

This commit is contained in:
David Parker
2021-09-10 16:55:47 -06:00
parent 28015a737a
commit 224c0ad217
17 changed files with 90 additions and 90 deletions
+8 -59
View File
@@ -1,63 +1,12 @@
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/StringLiterals:
inherit_from:
- .rubocop_airbnb.yml
- .rubocop_todo.yml
Airbnb/ClassOrModuleDeclaredInWrongFile:
Enabled: false
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
Layout/SpaceInsideHashLiteralBraces:
Airbnb/ConstAssignedInWrongFile:
Enabled: false
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
Layout/SpaceInsideBlockBraces:
Enabled: false
# Cop supports --auto-correct.
Layout/SpaceBeforeSemicolon:
Enabled: false
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SignalException:
Enabled: false
# Configuration parameters: Methods.
Style/SingleLineBlockParams:
Enabled: false
# Cop supports --auto-correct.
Style/PerlBackrefs:
Enabled: false
# Cop supports --auto-correct.
# Configuration parameters: AllowAsExpressionSeparator.
Style/Semicolon:
Enabled: false
Style/Documentation:
Enabled: false
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
Style/RegexpLiteral:
Enabled: false
# Cop supports --auto-correct.
Style/NumericLiterals:
MinDigits: 6
# Cop supports --auto-correct.
Lint/UnusedMethodArgument:
Enabled: false
# Cop supports --auto-correct.
Lint/UnusedBlockArgument:
Enabled: false
Lint/Void:
Enabled: false
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Enabled: false
Layout/AlignArguments:
EnforcedStyle: with_fixed_indentation
+2
View File
@@ -0,0 +1,2 @@
require:
- rubocop-airbnb
View File
+2
View File
@@ -26,4 +26,6 @@ group :development, :test do
gem 'pry'
# https://github.com/lsegal/yard
gem 'yard'
# https://github.com/airbnb/ruby/tree/master/rubocop-airbnb
gem 'rubocop-airbnb'
end
+23 -1
View File
@@ -1 +1,23 @@
TODO
# Documentation
Documentation can be generated with the command:
```sh
yard doc 'lib/**/*.rb'
```
# Specs
Specs can be run with the command:
```sh
bundle exec rake
```
# Rubocop
Rubocop can be run with the command:
```sh
rubocop 'lib'
```
+3 -2
View File
@@ -117,6 +117,7 @@ module NgrokAPI
end
private
def headers
{
'Authorization': "Bearer #{@api_key}",
@@ -140,8 +141,8 @@ module NgrokAPI
end
def get_uri(path, data: nil)
data = data != nil ? "?#{URI.encode_www_form(data)}" : ""
uri = URI("#{url(path)}#{data}")
data = !data.nil? ? "?#{URI.encode_www_form(data)}" : ""
URI("#{url(path)}#{data}")
end
def url(path)
+2
View File
@@ -46,9 +46,11 @@ module NgrokAPI
##
# Update the attributes of this API key.
#
# rubocop:disable LineLength
# @param [string] description human-readable description of what uses the API key to authenticate. optional, max 255 bytes.
# @param [string] metadata arbitrary user-defined data of this API key. optional, max 4096 bytes
# @return [NgrokAPI::Models::ApiKey] result from update request
# rubocop:enable LineLength
#
# https://ngrok.com/docs/api#api-api-keys-update
def update(description: nil, metadata: nil)
@@ -42,6 +42,7 @@ module NgrokAPI
end
##
# rubocop:disable LineLength
# Update this endpoint configuration. If a module is not specified in the update, it will not be modified.
# However, each module configuration that is specified will completely replace the existing value.
# There is no way to delete an existing module via this API, instead use the delete module API.
@@ -60,7 +61,8 @@ module NgrokAPI
# @param [string] logging logging module configuration
# @param [string] saml saml module configuration
# @param [string] oidc oidc module configuration
# @return
# @return [NgrokAPI::Models::EndpointConfiguration] result from update request
# rubocop:enable LineLength
#
# https://ngrok.com/docs/api#api-endpoint-configurations-update
def update(
+2 -2
View File
@@ -20,8 +20,8 @@ module NgrokAPI
@list_property = list_property
@next_page_uri = @result['next_page_uri']
@uri = @result['uri']
@items = @result[list_property].map do |result|
klass.new(client: client, result: result)
@items = @result[list_property].map do |item|
klass.new(client: client, result: item)
end
@iter = NgrokAPI::PagedIterator.new(
client: client,
+2
View File
@@ -60,6 +60,7 @@ module NgrokAPI
##
# Update the attributes of this reserved domain.
#
# rubocop:disable LineLength
# @param [string] description human-readable description of what this reserved domain will be used for
# @param [string] metadata arbitrary user-defined machine-readable data of this reserved domain. Optional, max 4096 bytes.
# @param [string] http_endpoint_configuration_id ID of an endpoint configuration of type http that will be used to handle inbound http traffic to this domain
@@ -67,6 +68,7 @@ module NgrokAPI
# @param [string] certificate_id ID of a user-uploaded TLS certificate to use for connections to targeting this domain. Optional, mutually exclusive with ``certificate_management_policy``.
# @param [string] certificate_management_policy configuration for automatic management of TLS certificates for this domain, or null if automatic management is disabled. Optional, mutually exclusive with ``certificate_id``.
# @return [NgrokAPI::Models::ReservedDomain] result from update request
# rubocop:enable LineLength
#
# https://ngrok.com/docs/api#api-reserved-domains-update
def update(
+2
View File
@@ -44,9 +44,11 @@ module NgrokAPI
##
# Update the attributes of this TLS Certificate.
#
# rubocop:disable LineLength
# @param [string] description human-readable description of this TLS certificate. optional, max 255 bytes.
# @param [string] metadata arbitrary user-defined machine-readable data of this TLS certificate. optional, max 4096 bytes.
# @return [NgrokAPI::Models::TlsCertificate] result from update request
# rubocop:enable LineLength
#
# https://ngrok.com/docs/api#api-tls-certificates-update
def update(description: nil, metadata: nil)
+12 -14
View File
@@ -24,20 +24,18 @@ module NgrokAPI
#
# @return [object] Returns an instance of a class.
def get_next
begin
item = @page.result[@list_property][@n]
raise "None" if item.nil?
self.n += 1
item
rescue => exception
if self.page.next_page_uri.nil?
# Handle / raise exception
else
res = @client.list(url: @page.next_page_uri)
self.n = 0
self.page = res
get_next
end
item = @page.result[@list_property][@n]
raise "None" if item.nil?
self.n += 1
item
rescue
if @page.next_page_uri.nil?
# Handle / raise exception
else
res = @client.list(url: @page.next_page_uri)
self.n = 0
self.page = res
get_next
end
end
end
+6 -2
View File
@@ -8,9 +8,9 @@ module NgrokAPI
# https://ngrok.com/docs/api#api-api-keys
class ApiKeysClient
# The List Property from the resulting API for list calls
LIST_PROPERTY = 'keys'.freeze
LIST_PROPERTY = 'keys'
# The API path for API keys
PATH = '/api_keys'.freeze
PATH = '/api_keys'
attr_reader :client
@@ -21,9 +21,11 @@ module NgrokAPI
##
# Create a new API key. The generated API key can be used to authenticate to the ngrok API.
#
# rubocop:disable LineLength
# @param [string] description human-readable description of what uses the API key to authenticate. optional, max 255 bytes.
# @param [string] metadata arbitrary user-defined data of this API key. optional, max 4096 bytes
# @return [NgrokAPI::Models::ApiKey] result from create request
# rubocop:enable LineLength
#
# https://ngrok.com/docs/api#api-api-keys-create
def create(description: nil, metadata: nil)
@@ -79,10 +81,12 @@ module NgrokAPI
##
# Update attributes of an API key by ID.
#
# rubocop:disable LineLength
# @param [string] id
# @param [string] description human-readable description of what uses the API key to authenticate. optional, max 255 bytes.
# @param [string] metadata arbitrary user-defined data of this API key. optional, max 4096 bytes
# @return [NgrokAPI::Models::ApiKey] result from update request
# rubocop:enable LineLength
#
# https://ngrok.com/docs/api#api-api-keys-update
def update(id: nil, description: nil, metadata: nil)
@@ -8,9 +8,9 @@ module NgrokAPI
# https://ngrok.com/docs/api#api-endpoint-configurations
class EndpointConfigurationsClient
# The List Property from the resulting API for list calls
LIST_PROPERTY = 'endpoint_configurations'.freeze
LIST_PROPERTY = 'endpoint_configurations'
# The API path for endpoint configurations
PATH = '/endpoint_configurations'.freeze
PATH = '/endpoint_configurations'
attr_reader :client
@@ -21,6 +21,7 @@ module NgrokAPI
##
# Create a new endpoint configuration
#
# rubocop:disable LineLength
# @param [string] description human-readable description of what this endpoint configuration will be do when applied or what traffic it will be applied to. Optional, max 255 bytes
# @param [string] metadata arbitrary user-defined machine-readable data of this endpoint configuration. Optional, max 4096 bytes.
# @param [string] type they type of traffic this endpoint configuration can be applied to. one of: ``http``, ``https``, ``tcp``
@@ -37,6 +38,7 @@ module NgrokAPI
# @param [string] saml saml module configuration
# @param [string] oidc oidc module configuration
# @return [NgrokAPI::Models::EndpointConfiguration] result from create request
# rubocop:enable LineLength
#
# https://ngrok.com/docs/api#api-endpoint-configurations-create
def create(
@@ -78,7 +80,9 @@ module NgrokAPI
end
##
# Delete an endpoint configuration. This operation will fail if the endpoint configuration is still referenced by any reserved domain or reserved address.
# Delete an endpoint configuration.
# This operation will fail if the endpoint configuration is still referenced by
# any reserved domain or reserved address.
#
# @param [string] id a resource identifier
# @return [nil] result from delete request
@@ -120,6 +124,7 @@ module NgrokAPI
end
##
# rubocop:disable LineLength
# Updates an endpoint configuration. If a module is not specified in the update, it will not be modified.
# However, each module configuration that is specified will completely replace the existing value.
# There is no way to delete an existing module via this API, instead use the delete module API.
@@ -140,6 +145,7 @@ module NgrokAPI
# @param [string] saml saml module configuration
# @param [string] oidc oidc module configuration
# @return [NgrokAPI::Models::EndpointConfiguration] result from update request
# rubocop:enable LineLength
#
# https://ngrok.com/docs/api#api-endpoint-configurations-update
def update(
@@ -8,9 +8,9 @@ module NgrokAPI
# https://ngrok.com/docs/api#api-reserved-domains
class ReservedDomainsClient
# The List Property from the resulting API for list calls
LIST_PROPERTY = 'reserved_domains'.freeze
LIST_PROPERTY = 'reserved_domains'
# The API path for reserved domains
PATH = '/reserved_domains'.freeze
PATH = '/reserved_domains'
attr_reader :client
@@ -21,6 +21,7 @@ module NgrokAPI
##
# Create a new reserved domain.
#
# rubocop:disable LineLength
# @param [string] name the domain name to reserve. It may be a full domain name like app.example.com. If the name does not contain a '.' it will reserve that subdomain on ngrok.io.
# @param [string] region reserve the domain in this geographic ngrok datacenter. Optional, default is us. (au, eu, ap, us, jp, in, sa)
# @param [string] description human-readable description of what this reserved domain will be used for
@@ -30,6 +31,7 @@ module NgrokAPI
# @param [string] certificate_id ID of a user-uploaded TLS certificate to use for connections to targeting this domain. Optional, mutually exclusive with ``certificate_management_policy``.
# @param [string] certificate_management_policy configuration for automatic management of TLS certificates for this domain, or null if automatic management is disabled. Optional, mutually exclusive with ``certificate_id``.
# @return [NgrokAPI::Models::ReservedDomain] result from create request
# rubocop:enable LineLength
#
# https://ngrok.com/docs/api#api-reserved-domains-create
def create(
@@ -101,6 +103,7 @@ module NgrokAPI
##
# Update the attributes of a reserved domain.
#
# rubocop:disable LineLength
# @param [string] id
# @param [string] description human-readable description of what this reserved domain will be used for
# @param [string] metadata arbitrary user-defined machine-readable data of this reserved domain. Optional, max 4096 bytes.
@@ -109,6 +112,7 @@ module NgrokAPI
# @param [string] certificate_id ID of a user-uploaded TLS certificate to use for connections to targeting this domain. Optional, mutually exclusive with ``certificate_management_policy``.
# @param [string] certificate_management_policy configuration for automatic management of TLS certificates for this domain, or null if automatic management is disabled. Optional, mutually exclusive with ``certificate_id``.
# @return [NgrokAPI::Models::ReservedDomain] result from update request
# rubocop:enable LineLength
#
# https://ngrok.com/docs/api#api-reserved-domains-update
def update(
@@ -8,9 +8,9 @@ module NgrokAPI
# https://ngrok.com/docs/api#api-tls-certificates
class TlsCertificatesClient
# The List Property from the resulting API for list calls
LIST_PROPERTY = 'tls_certificates'.freeze
LIST_PROPERTY = 'tls_certificates'
# The API path for tls certificates
PATH = '/tls_certificates'.freeze
PATH = '/tls_certificates'
attr_reader :client
@@ -21,11 +21,13 @@ module NgrokAPI
##
# Upload a new TLS certificate.
#
# rubocop:disable LineLength
# @param [string] description human-readable description of this TLS certificate. optional, max 255 bytes.
# @param [string] metadata arbitrary user-defined machine-readable data of this TLS certificate. optional, max 4096 bytes.
# @param [string] certificate_pem chain of PEM-encoded certificates, leaf first. See `Certificate Bundles` <https://ngrok.com/docs/api#tls-certificates-pem>`_.
# @param [string] private_key_pem private key for the TLS certificate, PEM-encoded. See `Private Keys` <https://ngrok.com/docs/ngrok-link#tls-certificates-key>`_.
# @return [NgrokAPI::Models::TlsCertificate] result from create request
# rubocop:enable LineLength
#
# https://ngrok.com/docs/api#api-tls-certificates-create
def create(
@@ -89,10 +91,12 @@ module NgrokAPI
##
# Update attributes of a TLS Certificate by ID.
#
# rubocop:disable LineLength
# @param [string] id
# @param [string] description human-readable description of this TLS certificate. optional, max 255 bytes.
# @param [string] metadata arbitrary user-defined machine-readable data of this TLS certificate. optional, max 4096 bytes.
# @return [NgrokAPI::Models::TlsCertificate] result from update request
# rubocop:enable LineLength
#
# https://ngrok.com/docs/api#api-tls-certificates-update
def update(
+2 -2
View File
@@ -54,13 +54,13 @@ RSpec.describe NgrokAPI::Models::Listable do
end
describe "keys" do
it "should consistent of ApiKeys" do
it "consistent of ApiKeys" do
expect(@listable.items.size).to eq @result['keys'].size
end
end
describe "iter" do
it "should be a PagedIterator" do
it "is a PagedIterator" do
expect(@listable.iter.class).to eq NgrokAPI::PagedIterator
end
end