From 382764bb44521daa3b77694fb5c8c30bff97230b Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Mon, 2 Sep 2024 13:25:20 -0700 Subject: [PATCH 1/9] Update dependencies --- .rubocop.yml | 26 +++++++++++++------------- instapaper.gemspec | 4 ++-- lib/instapaper/api/folders.rb | 2 +- lib/instapaper/bookmark_list.rb | 6 +++--- lib/instapaper/http/utils.rb | 2 +- spec/instapaper/http/response_spec.rb | 3 +++ 6 files changed, 23 insertions(+), 20 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 6cca6d2..eb6f492 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,9 +1,9 @@ AllCops: Include: - - './Rakefile' - - 'instapaper.gemspec' - - 'lib/**/*.rb' - - 'spec/**/*.rb' + - "./Rakefile" + - "instapaper.gemspec" + - "lib/**/*.rb" + - "spec/**/*.rb" DisplayCopNames: true NewCops: enable @@ -15,7 +15,7 @@ Metrics/BlockLength: Metrics/BlockNesting: Max: 2 -Metrics/LineLength: +Layout/LineLength: AllowURI: true Enabled: false @@ -29,10 +29,10 @@ Metrics/ParameterLists: Style/CollectionMethods: PreferredMethods: - map: 'collect' - reduce: 'inject' - find: 'detect' - find_all: 'select' + map: "collect" + reduce: "inject" + find: "detect" + find_all: "select" Style/Documentation: Enabled: false @@ -53,15 +53,15 @@ Layout/SpaceInsideHashLiteralBraces: EnforcedStyle: no_space Style/TrailingCommaInArguments: - EnforcedStyleForMultiline: 'comma' + EnforcedStyleForMultiline: "comma" Style/TrailingCommaInArrayLiteral: - EnforcedStyleForMultiline: 'comma' + EnforcedStyleForMultiline: "comma" Style/TrailingCommaInHashLiteral: - EnforcedStyleForMultiline: 'comma' + EnforcedStyleForMultiline: "comma" -Style/FileName: +Naming/FileName: Exclude: - Rakefile - Gemfile diff --git a/instapaper.gemspec b/instapaper.gemspec index 6c6f97b..1eb28b4 100644 --- a/instapaper.gemspec +++ b/instapaper.gemspec @@ -7,8 +7,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'http', '>= 2', '< 6' spec.add_dependency 'multi_json', '~> 1' spec.add_dependency 'simple_oauth', '~> 0.3' - spec.add_dependency 'virtus', '~> 1' - spec.add_development_dependency 'bundler' + spec.add_dependency 'virtus', '~> 2' spec.author = 'Steve Agalloco' spec.description = "Ruby Client for Instapaper's Full API" spec.email = 'steve.agalloco@gmail.com' @@ -20,4 +19,5 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 2.0.0' spec.summary = 'Ruby Instapaper Client' spec.version = Instapaper::VERSION + spec.metadata['rubygems_mfa_required'] = 'true' end diff --git a/lib/instapaper/api/folders.rb b/lib/instapaper/api/folders.rb index ad4c435..394c540 100644 --- a/lib/instapaper/api/folders.rb +++ b/lib/instapaper/api/folders.rb @@ -27,7 +27,7 @@ def delete_folder(folder_id) # @param order [Array] An array of folder_id:position pairs joined by commas. # @example Ordering folder_ids 100, 200, and 300 # Instapaper.set_order(['100:1','200:2','300:3']) - def set_order(order = []) # rubocop:disable Naming/AccessorMethodName + def set_order(order = []) perform_post_with_objects('/api/1.1/folders/set_order', {order: order.join(',')}, Instapaper::Folder) end end diff --git a/lib/instapaper/bookmark_list.rb b/lib/instapaper/bookmark_list.rb index 777d490..5307a56 100644 --- a/lib/instapaper/bookmark_list.rb +++ b/lib/instapaper/bookmark_list.rb @@ -8,9 +8,9 @@ class BookmarkList values do attribute :user, Instapaper::User - attribute :bookmarks, Array[Instapaper::Bookmark] - attribute :highlights, Array[Instapaper::Highlight] - attribute :delete_ids, Array[Integer] + attribute :bookmarks, [Instapaper::Bookmark] + attribute :highlights, [Instapaper::Highlight] + attribute :delete_ids, [Integer] end def each(&block) diff --git a/lib/instapaper/http/utils.rb b/lib/instapaper/http/utils.rb index 972fa6e..8a19522 100644 --- a/lib/instapaper/http/utils.rb +++ b/lib/instapaper/http/utils.rb @@ -42,7 +42,7 @@ def perform_post_with_object(path, options, klass) # @param klass [Class] def perform_request_with_object(request_method, path, options, klass) response = perform_request(request_method, path, options) - response = response.is_a?(Array) ? response.first : response + response = response.first if response.is_a?(Array) klass.new(coerce_hash(response)) end diff --git a/spec/instapaper/http/response_spec.rb b/spec/instapaper/http/response_spec.rb index 28f5967..d206ae9 100644 --- a/spec/instapaper/http/response_spec.rb +++ b/spec/instapaper/http/response_spec.rb @@ -30,12 +30,15 @@ def parse(_) describe '#valid?' do context 'when http error' do + it 'should be invalid' end context 'when body unparseable' do + it 'should be invalid' end context 'when error in body' do + it 'should be invalid' end end end From f23b579417de4d656ff2b1dc2dfc1caeb9862f73 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 8 Jun 2025 10:37:37 -0700 Subject: [PATCH 2/9] Update gems --- .rubocop.yml | 3 +++ Gemfile | 1 + instapaper.gemspec | 2 +- lib/instapaper/api/folders.rb | 2 +- lib/instapaper/api/highlights.rb | 2 +- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index eb6f492..8b76fd4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,6 +7,9 @@ AllCops: DisplayCopNames: true NewCops: enable +Gemspec/RequireMFA: + Enabled: false + Metrics/BlockLength: Max: 36 Exclude: diff --git a/Gemfile b/Gemfile index 621ba6f..f69d498 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,7 @@ gem 'jruby-openssl', platforms: :jruby gem 'json', platforms: :mri_19 group :development do + gem 'bundler' gem 'kramdown' end diff --git a/instapaper.gemspec b/instapaper.gemspec index 1eb28b4..671489a 100644 --- a/instapaper.gemspec +++ b/instapaper.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'http', '>= 2', '< 6' spec.add_dependency 'multi_json', '~> 1' spec.add_dependency 'simple_oauth', '~> 0.3' - spec.add_dependency 'virtus', '~> 2' + spec.add_dependency 'virtus', '~> 1' spec.author = 'Steve Agalloco' spec.description = "Ruby Client for Instapaper's Full API" spec.email = 'steve.agalloco@gmail.com' diff --git a/lib/instapaper/api/folders.rb b/lib/instapaper/api/folders.rb index 394c540..a2dc63a 100644 --- a/lib/instapaper/api/folders.rb +++ b/lib/instapaper/api/folders.rb @@ -18,7 +18,7 @@ def add_folder(title) # Deletes the folder and moves any articles in it to the Archive. # @param folder_id [String] The id of the folder. - def delete_folder(folder_id) + def delete_folder(folder_id) # rubocop:disable Naming/PredicateMethod perform_post_with_unparsed_response('/api/1.1/folders/delete', folder_id: folder_id) true end diff --git a/lib/instapaper/api/highlights.rb b/lib/instapaper/api/highlights.rb index b39e94c..d6e1b5a 100644 --- a/lib/instapaper/api/highlights.rb +++ b/lib/instapaper/api/highlights.rb @@ -24,7 +24,7 @@ def add_highlight(bookmark_id, options = {}) # Delete a highlight # @param highlight_id [String, Integer] # @return [Boolean] - def delete_highlight(highlight_id, options = {}) + def delete_highlight(highlight_id, options = {}) # rubocop:disable Naming/PredicateMethod perform_post_with_unparsed_response("/api/1.1/highlights/#{highlight_id}/delete", options) true end From 98a85f18d63d031e7da566b190e79439bd414e67 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Thu, 2 Jan 2025 11:49:57 -0800 Subject: [PATCH 3/9] Update GitHub workflows --- .github/workflows/ci.yml | 7 +++---- .github/workflows/linter.yml | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62cf909..417fa52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: tests: strategy: matrix: - ruby: [ '2.6', '2.7', '3.0' ] + ruby: [ '3.1', '3.2', '3.3', '3.4' ] name: Tests - Ruby ${{ matrix.ruby }} # Set the type of machine to run on @@ -19,9 +19,9 @@ jobs: steps: # Checks out a copy of your repository on the ubuntu-latest machine - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: vendor/bundle key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} @@ -42,4 +42,3 @@ jobs: - name: Run tests run: | bundle exec rake test - diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 42c317f..4b87a48 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -36,7 +36,7 @@ jobs: # Checkout the code base # ########################## - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Full git history is needed to get a proper list of changed files within `super-linter` fetch-depth: 0 From 26cb3d5b6d99e4a60f7df91994f84fc783401936 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Thu, 2 Jan 2025 12:09:44 -0800 Subject: [PATCH 4/9] More updates --- .github/workflows/ci.yml | 4 ++-- .github/workflows/linter.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 417fa52..710cdbd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,9 +19,9 @@ jobs: steps: # Checks out a copy of your repository on the ubuntu-latest machine - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: vendor/bundle key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 4b87a48..5c253c5 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -36,7 +36,7 @@ jobs: # Checkout the code base # ########################## - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # Full git history is needed to get a proper list of changed files within `super-linter` fetch-depth: 0 @@ -45,7 +45,7 @@ jobs: # Run Linter against code base # ################################ - name: Lint Code Base - uses: github/super-linter@v3 + uses: github/super-linter@v7 env: VALIDATE_ALL_CODEBASE: false DEFAULT_BRANCH: main From cd2806ae99c041c8b6675b384b9fa3a7b40b4705 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 8 Jun 2025 10:44:32 -0700 Subject: [PATCH 5/9] Drop EOL Ruby 3.1 from test matrix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 710cdbd..4d90acb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: tests: strategy: matrix: - ruby: [ '3.1', '3.2', '3.3', '3.4' ] + ruby: [ '3.4', '3.3', '3.2' ] name: Tests - Ruby ${{ matrix.ruby }} # Set the type of machine to run on From 0498bc56847559d9716ff23856e94c18b37da425 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 8 Jun 2025 12:19:10 -0700 Subject: [PATCH 6/9] Ignore code duplication in specs --- .jscpd.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .jscpd.json diff --git a/.jscpd.json b/.jscpd.json new file mode 100644 index 0000000..6db8ed8 --- /dev/null +++ b/.jscpd.json @@ -0,0 +1,4 @@ +{ + "threshold": 1, + "ignore": ["spec/**"] +} \ No newline at end of file From b12e3b5b1315f0817e3f648037ef6281ea80b8d6 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 8 Jun 2025 13:24:05 -0700 Subject: [PATCH 7/9] Fix lint errors --- .github/workflows/ci.yml | 7 +++++-- .github/workflows/linter.yml | 5 ++++- .jscpd.json | 5 +++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d90acb..74f0dca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,10 @@ name: CI on: pull_request: - branches: [ '**' ] + branches: ["**"] + +permissions: + contents: read jobs: # Set the job key. The key is displayed as the job name @@ -10,7 +13,7 @@ jobs: tests: strategy: matrix: - ruby: [ '3.4', '3.3', '3.2' ] + ruby: ["3.4", "3.3", "3.2"] name: Tests - Ruby ${{ matrix.ruby }} # Set the type of machine to run on diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 5c253c5..36cffbe 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -16,7 +16,10 @@ name: Lint Code Base ############################# on: pull_request: - branches: [ '**' ] + branches: ["**"] + +permissions: + contents: read ############### # Set the Job # diff --git a/.jscpd.json b/.jscpd.json index 6db8ed8..4a9eb29 100644 --- a/.jscpd.json +++ b/.jscpd.json @@ -1,4 +1,5 @@ { "threshold": 1, - "ignore": ["spec/**"] -} \ No newline at end of file + "ignore": ["spec/**"], + "reporters": ["threshold"] +} From 0568387e4f6fab3b935c7b7dd685ce38aff01a8c Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 8 Jun 2025 13:27:49 -0700 Subject: [PATCH 8/9] More lint fixes --- .github/workflows/linter.yml | 2 ++ .jscpd.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 36cffbe..9c792f7 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -20,6 +20,8 @@ on: permissions: contents: read + statuses: write + checks: write ############### # Set the Job # diff --git a/.jscpd.json b/.jscpd.json index 4a9eb29..e6b45d4 100644 --- a/.jscpd.json +++ b/.jscpd.json @@ -1,5 +1,5 @@ { - "threshold": 1, + "threshold": 0.5, "ignore": ["spec/**"], "reporters": ["threshold"] } From b59815ebac2efac10ec78c299d251ca787b9f9c0 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 8 Jun 2025 13:48:37 -0700 Subject: [PATCH 9/9] Ok how about now --- .jscpd.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jscpd.json b/.jscpd.json index e6b45d4..0d56032 100644 --- a/.jscpd.json +++ b/.jscpd.json @@ -1,5 +1,5 @@ { - "threshold": 0.5, + "threshold": 2, "ignore": ["spec/**"], "reporters": ["threshold"] }