diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 889623f..29a6a9c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,32 +1,18 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2022-08-11 09:16:56 UTC using RuboCop version 1.34.1. +# on 2023-10-16 11:42:28 UTC using RuboCop version 1.57.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 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Include. -# Include: **/*.gemspec -Gemspec/RequireMFA: - Exclude: - - 'simple_review_app.gemspec' - -# Offense count: 1 -# Configuration parameters: Include. +# Configuration parameters: Severity, Include. # Include: **/*.gemspec Gemspec/RequiredRubyVersion: Exclude: - 'simple_review_app.gemspec' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLineAfterGuardClause: - Exclude: - - 'lib/simple_review_app.rb' - # Offense count: 1 # Configuration parameters: AllowedMethods. # AllowedMethods: enums @@ -41,12 +27,12 @@ Lint/NonAtomicFileOperation: - 'lib/simple_review_app/pull_request.rb' # Offense count: 1 -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes. +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 18 # Offense count: 1 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods. +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Max: 11 @@ -85,13 +71,13 @@ RSpec/LeakyConstantDeclaration: Exclude: - 'spec/logger_spec.rb' -# Offense count: 5 +# Offense count: 3 # Configuration parameters: . # SupportedStyles: have_received, receive RSpec/MessageSpies: EnforcedStyle: receive -# Offense count: 2 +# Offense count: 1 RSpec/MultipleExpectations: Max: 2 @@ -100,8 +86,9 @@ RSpec/MultipleExpectations: RSpec/MultipleMemoizedHelpers: Max: 6 -# Offense count: 20 -# Configuration parameters: IgnoreSharedExamples. +# Offense count: 15 +# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. +# SupportedStyles: always, named_only RSpec/NamedSubject: Exclude: - 'spec/docker_compose_file_spec.rb' @@ -117,22 +104,21 @@ RSpec/PredicateMatcher: Exclude: - 'spec/pull_request_spec.rb' -# Offense count: 8 -RSpec/SubjectStub: +# Offense count: 4 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. +# Include: **/*_spec.rb +RSpec/SpecFilePathFormat: Exclude: + - '**/spec/routing/**/*' + - 'spec/docker_compose_file_spec.rb' + - 'spec/logger_spec.rb' + - 'spec/pull_request_collection_spec.rb' - 'spec/pull_request_spec.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/ExplicitBlockArgument: - Exclude: - - 'lib/simple_review_app/review_app.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/FileWrite: +# Offense count: 5 +RSpec/SubjectStub: Exclude: - - 'lib/simple_review_app/docker_compose_file.rb' + - 'spec/pull_request_spec.rb' # Offense count: 1 # Configuration parameters: AllowedMethods. @@ -140,17 +126,3 @@ Style/FileWrite: Style/OptionalBooleanParameter: Exclude: - 'lib/simple_review_app/review_app.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantFileExtensionInRequire: - Exclude: - - 'lib/simple_review_app/pull_request_collection.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiterals: - Exclude: - - 'lib/simple_review_app.rb' diff --git a/Gemfile.lock b/Gemfile.lock index c4f5d27..fa03220 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -90,11 +90,11 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.29.0) parser (>= 3.2.1.0) - rubocop-capybara (2.18.0) + rubocop-capybara (2.19.0) rubocop (~> 1.41) - rubocop-factory_bot (2.23.1) + rubocop-factory_bot (2.24.0) rubocop (~> 1.33) - rubocop-rspec (2.23.2) + rubocop-rspec (2.24.1) rubocop (~> 1.33) rubocop-capybara (~> 2.17) rubocop-factory_bot (~> 2.22) diff --git a/lib/simple_review_app.rb b/lib/simple_review_app.rb index cbcbc5f..f8645d9 100644 --- a/lib/simple_review_app.rb +++ b/lib/simple_review_app.rb @@ -102,6 +102,7 @@ def data_directory def create_data_directory return if File.exist?(data_directory) + msg = "Data directory #{data_directory} does not exist, creating it." logger.info(msg) FileUtils.mkdir_p(data_directory) @@ -135,11 +136,12 @@ def credentials? def client return @client if @client.present? + if credentials? logger.info "Authenticating to GitHub with username #{github_username}." @client = Octokit::Client.new(login: github_username, password: github_password) elsif github_access_token.present? - logger.info "Authenticating to GitHub with access token." + logger.info 'Authenticating to GitHub with access token.' @client = Octokit::Client.new(access_token: github_access_token) else logger.info 'Using github API as anonymous user.' diff --git a/lib/simple_review_app/docker_compose_file.rb b/lib/simple_review_app/docker_compose_file.rb index 2ab8e3f..639b511 100644 --- a/lib/simple_review_app/docker_compose_file.rb +++ b/lib/simple_review_app/docker_compose_file.rb @@ -18,9 +18,7 @@ def content def update @content = template.render(attributes) - File.open(path, 'w') do |f| - f.write(@content) - end + File.write(path, @content) self end diff --git a/lib/simple_review_app/pull_request_collection.rb b/lib/simple_review_app/pull_request_collection.rb index ca3bdd1..992a05c 100644 --- a/lib/simple_review_app/pull_request_collection.rb +++ b/lib/simple_review_app/pull_request_collection.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'octokit.rb' +require 'octokit' require 'active_model' require_relative 'logger' require_relative 'pull_request' diff --git a/lib/simple_review_app/review_app.rb b/lib/simple_review_app/review_app.rb index b0e5c67..7f7772e 100644 --- a/lib/simple_review_app/review_app.rb +++ b/lib/simple_review_app/review_app.rb @@ -153,10 +153,8 @@ def project_directory File.join(directory, project_name) end - def do_in_project_directory - Dir.chdir(project_directory) do - yield - end + def do_in_project_directory(&) + Dir.chdir(project_directory, &) end end end diff --git a/simple_review_app.gemspec b/simple_review_app.gemspec index 680c338..096008a 100644 --- a/simple_review_app.gemspec +++ b/simple_review_app.gemspec @@ -18,4 +18,5 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'octokit', '>= 4', '< 8' s.add_runtime_dependency 'rake', '>= 12.3', '< 14.0' s.add_runtime_dependency 'zaru', '>= 0.2', '< 2.0' + s.metadata['rubygems_mfa_required'] = 'true' end diff --git a/spec/pull_request_collection_spec.rb b/spec/pull_request_collection_spec.rb index 64f20a3..6fd6cba 100644 --- a/spec/pull_request_collection_spec.rb +++ b/spec/pull_request_collection_spec.rb @@ -4,7 +4,7 @@ require 'octokit' require 'simple_review_app/pull_request_collection' -describe SimpleReviewApp::PullRequestCollection, vcr: true do +describe SimpleReviewApp::PullRequestCollection, :vcr do let(:logger) { double } let(:label) { 'review-lab' } diff --git a/spec/pull_request_spec.rb b/spec/pull_request_spec.rb index 960b576..95a9b2c 100644 --- a/spec/pull_request_spec.rb +++ b/spec/pull_request_spec.rb @@ -4,7 +4,7 @@ require 'octokit' require 'simple_review_app/pull_request' -describe SimpleReviewApp::PullRequest, vcr: true do +describe SimpleReviewApp::PullRequest, :vcr do subject do SimpleReviewApp::PullRequest.new( content:,