diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62cf909..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: [ '2.6', '2.7', '3.0' ] + ruby: ["3.4", "3.3", "3.2"] name: Tests - Ruby ${{ matrix.ruby }} # Set the type of machine to run on @@ -19,9 +22,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@v4 - - uses: actions/cache@v2 + - uses: actions/cache@v4 with: path: vendor/bundle key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} @@ -42,4 +45,3 @@ jobs: - name: Run tests run: | bundle exec rake test - diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 42c317f..9c792f7 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -16,7 +16,12 @@ name: Lint Code Base ############################# on: pull_request: - branches: [ '**' ] + branches: ["**"] + +permissions: + contents: read + statuses: write + checks: write ############### # Set the Job # @@ -36,7 +41,7 @@ jobs: # Checkout the code base # ########################## - name: Checkout Code - uses: actions/checkout@v2 + 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 +50,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 diff --git a/.jscpd.json b/.jscpd.json new file mode 100644 index 0000000..0d56032 --- /dev/null +++ b/.jscpd.json @@ -0,0 +1,5 @@ +{ + "threshold": 2, + "ignore": ["spec/**"], + "reporters": ["threshold"] +} diff --git a/.rubocop.yml b/.rubocop.yml index 6cca6d2..8b76fd4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,12 +1,15 @@ AllCops: Include: - - './Rakefile' - - 'instapaper.gemspec' - - 'lib/**/*.rb' - - 'spec/**/*.rb' + - "./Rakefile" + - "instapaper.gemspec" + - "lib/**/*.rb" + - "spec/**/*.rb" DisplayCopNames: true NewCops: enable +Gemspec/RequireMFA: + Enabled: false + Metrics/BlockLength: Max: 36 Exclude: @@ -15,7 +18,7 @@ Metrics/BlockLength: Metrics/BlockNesting: Max: 2 -Metrics/LineLength: +Layout/LineLength: AllowURI: true Enabled: false @@ -29,10 +32,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 +56,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/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 6c6f97b..671489a 100644 --- a/instapaper.gemspec +++ b/instapaper.gemspec @@ -8,7 +8,6 @@ Gem::Specification.new do |spec| spec.add_dependency 'multi_json', '~> 1' spec.add_dependency 'simple_oauth', '~> 0.3' spec.add_dependency 'virtus', '~> 1' - spec.add_development_dependency 'bundler' 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..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 @@ -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/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 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