Skip to content

Commit

Permalink
Switch from rubocop to standard gem for linting
Browse files Browse the repository at this point in the history
  • Loading branch information
nertzy committed Dec 28, 2023
1 parent f8a8639 commit d179680
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 127 deletions.
17 changes: 0 additions & 17 deletions .codeclimate.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .rubocop.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ruby_version: 3.0

plugins:
- standard-performance
- standard-rails:
target_rails_version: 6.1
13 changes: 4 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,16 @@ if ENV["ACTIVE_RECORD_BRANCH"]
gem "arel", git: "https://github.com/rails/arel.git" if ENV.fetch("ACTIVE_RECORD_BRANCH", nil) == "master"
end

gem "activerecord", ENV.fetch("ACTIVE_RECORD_VERSION", nil) if ENV["ACTIVE_RECORD_VERSION"]
gem "activerecord", ENV.fetch("ACTIVE_RECORD_VERSION", nil) if ENV["ACTIVE_RECORD_VERSION"] # standard:disable Bundler/DuplicatedGem

gem "pry"
gem "rake"
gem "rspec"
gem "rubocop"
gem "rubocop-performance"
gem "rubocop-rails"
gem "rubocop-rake"
gem "rubocop-rspec"
gem "simplecov"
gem "simplecov-lcov"
gem "standard"
gem "standard-rails"
gem "standard-rspec"
gem "standard", require: false
gem "standard-rails", require: false
gem "standard-rspec", require: false
gem "undercover"
gem "warning"
gem "with_model"
7 changes: 2 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ Bundler::GemHelper.install_tasks
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)

require "rubocop/rake_task"
RuboCop::RakeTask.new do |t|
t.options = %w[--display-cop-names]
end
require "standard/rake"

desc "Check test coverage"
task :undercover do
system("git fetch --unshallow") if ENV["CI"]
exit(1) unless system("bin/undercover --compare origin/master")
end

task default: %w[spec rubocop undercover]
task default: %w[spec standard undercover]
2 changes: 1 addition & 1 deletion lib/pg_search/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "logger"

module PgSearch
class Document < ActiveRecord::Base
class Document < ActiveRecord::Base # standard:disable Rails/ApplicationRecord
include PgSearch::Model

self.table_name = "pg_search_documents"
Expand Down
4 changes: 2 additions & 2 deletions lib/pg_search/multisearchable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ def update_pg_search_document
if should_have_document
create_or_update_pg_search_document
else
pg_search_document&.destroy
pg_search_document&.destroy # standard:disable Rails/SaveBang
end
end

def create_or_update_pg_search_document
if !pg_search_document
create_pg_search_document(pg_search_document_attrs)
elsif should_update_pg_search_document?
pg_search_document.update(pg_search_document_attrs)
pg_search_document.update(pg_search_document_attrs) # standard:disable Rails/SaveBang
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/integration/associations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "spec_helper"

# rubocop:disable RSpec/NestedGroups
# standard:disable RSpec/NestedGroups
describe "a pg_search_scope" do
context "when joining to another table" do
context "without an :against" do
Expand Down Expand Up @@ -418,10 +418,10 @@
end

it "finds records of the other model" do
included_associated_1 = AssociatedModel.create(content: "foo bar")
included_associated_2 = AssociatedModel.create(content: "foo baz")
excluded_associated_1 = AssociatedModel.create(content: "baz quux")
excluded_associated_2 = AssociatedModel.create(content: "baz bar")
included_associated_1 = AssociatedModel.create!(content: "foo bar")
included_associated_2 = AssociatedModel.create!(content: "foo baz")
excluded_associated_1 = AssociatedModel.create!(content: "baz quux")
excluded_associated_2 = AssociatedModel.create!(content: "baz bar")

included = [
ModelWithAssociation.create(associated_models: [included_associated_1]),
Expand Down Expand Up @@ -484,4 +484,4 @@
end
end
end
# rubocop:enable RSpec/NestedGroups
# standard:enable RSpec/NestedGroups
8 changes: 4 additions & 4 deletions spec/integration/pg_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "spec_helper"

# rubocop:disable RSpec/NestedGroups
# standard:disable RSpec/NestedGroups
describe "an Active Record model which includes PgSearch" do
with_model :ModelWithPgSearch do
table do |t|
Expand Down Expand Up @@ -1059,8 +1059,8 @@
SET content_tsvector = to_tsvector('english'::regconfig, #{Post.quoted_table_name}."content")
SQL

expected.comments.create(body: "commentone")
unexpected.comments.create(body: "commentwo")
expected.comments.create!(body: "commentone")
unexpected.comments.create!(body: "commentwo")

Post.pg_search_scope :search_by_content_with_tsvector,
associated_against: {comments: [:body]},
Expand Down Expand Up @@ -1355,4 +1355,4 @@
end
end
end
# rubocop:enable RSpec/NestedGroups
# standard:enable RSpec/NestedGroups
4 changes: 2 additions & 2 deletions spec/lib/pg_search/configuration/association_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "spec_helper"

# rubocop:disable RSpec/NestedGroups
# standard:disable RSpec/NestedGroups
describe PgSearch::Configuration::Association do
with_model :Avatar do
table do |t|
Expand Down Expand Up @@ -139,4 +139,4 @@
end
end
end
# rubocop:enable RSpec/NestedGroups
# standard:enable RSpec/NestedGroups
4 changes: 2 additions & 2 deletions spec/lib/pg_search/features/trigram_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "spec_helper"
require "ostruct"

# rubocop:disable RSpec/MultipleMemoizedHelpers, RSpec/NestedGroups
# standard:disable RSpec/MultipleMemoizedHelpers, RSpec/NestedGroups
describe PgSearch::Features::Trigram do
subject(:feature) { described_class.new(query, options, columns, Model, normalizer) }

Expand Down Expand Up @@ -109,4 +109,4 @@
end
end
end
# rubocop:enable RSpec/MultipleMemoizedHelpers, RSpec/NestedGroups
# standard:enable RSpec/MultipleMemoizedHelpers, RSpec/NestedGroups
12 changes: 6 additions & 6 deletions spec/lib/pg_search/features/tsearch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
end

context "when options[:dictionary] is passed" do
# rubocop:disable RSpec/ExampleLength
# standard:disable RSpec/ExampleLength
it "uses the provided dictionary" do
query = "query"
columns = [
Expand All @@ -193,11 +193,11 @@

expect(feature.highlight.to_sql).to eq(expected_sql)
end
# rubocop:enable RSpec/ExampleLength
# standard:enable RSpec/ExampleLength
end

context "when options[:highlight] has options set" do
# rubocop:disable RSpec/ExampleLength
# standard:disable RSpec/ExampleLength
it "passes the options to ts_headline" do
query = "query"
columns = [
Expand Down Expand Up @@ -225,9 +225,9 @@

expect(feature.highlight.to_sql).to eq(expected_sql)
end
# rubocop:enable RSpec/ExampleLength
# standard:enable RSpec/ExampleLength

# rubocop:disable RSpec/ExampleLength
# standard:disable RSpec/ExampleLength
it "passes deprecated options to ts_headline" do
query = "query"
columns = [
Expand Down Expand Up @@ -256,7 +256,7 @@

expect(highlight_sql).to eq(expected_sql)
end
# rubocop:enable RSpec/ExampleLength
# standard:enable RSpec/ExampleLength
end
end
end
24 changes: 12 additions & 12 deletions spec/lib/pg_search/multisearch/rebuilder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "spec_helper"

# rubocop:disable RSpec/NestedGroups
# standard:disable RSpec/NestedGroups
describe PgSearch::Multisearch::Rebuilder do
with_table "pg_search_documents", &DOCUMENTS_SCHEMA

Expand Down Expand Up @@ -108,7 +108,7 @@ def rebuild_pg_search_documents
end
end

# rubocop:disable RSpec/ExampleLength
# standard:disable RSpec/ExampleLength
it "executes the default SQL" do
time = Time.utc(2001, 1, 1, 0, 0, 0)
rebuilder = described_class.new(Model, -> { time })
Expand Down Expand Up @@ -137,7 +137,7 @@ def rebuild_pg_search_documents
expect(executed_sql.length).to eq(1)
expect(executed_sql.first.strip).to eq(expected_sql.strip)
end
# rubocop:enable RSpec/ExampleLength
# standard:enable RSpec/ExampleLength

context "with a model with a camel case column" do
with_model :ModelWithCamelCaseColumn do
Expand Down Expand Up @@ -170,7 +170,7 @@ def rebuild_pg_search_documents
end
end

# rubocop:disable RSpec/ExampleLength
# standard:disable RSpec/ExampleLength
it "generates SQL with the correct primary key" do
time = Time.utc(2001, 1, 1, 0, 0, 0)
rebuilder = described_class.new(ModelWithNonStandardPrimaryKey, -> { time })
Expand Down Expand Up @@ -199,7 +199,7 @@ def rebuild_pg_search_documents
expect(executed_sql.length).to eq(1)
expect(executed_sql.first.strip).to eq(expected_sql.strip)
end
# rubocop:enable RSpec/ExampleLength
# standard:enable RSpec/ExampleLength
end
end

Expand All @@ -215,7 +215,7 @@ def foo
end
end

# rubocop:disable RSpec/ExampleLength
# standard:disable RSpec/ExampleLength
it "calls update_pg_search_document on each record" do
record = Model.create!

Expand All @@ -241,7 +241,7 @@ def foo

expect(record.pg_search_document).to be_present
end
# rubocop:enable RSpec/ExampleLength
# standard:enable RSpec/ExampleLength
end

context "when only additional_attributes is set" do
Expand Down Expand Up @@ -285,7 +285,7 @@ def foo
end
end

# rubocop:disable RSpec/ExampleLength
# standard:disable RSpec/ExampleLength
it "calls update_pg_search_document on each record" do
record_1 = Model.create!(active: true)
record_2 = Model.create!(active: false)
Expand All @@ -311,7 +311,7 @@ def foo
expect(record_1.pg_search_document).to be_present
expect(record_2.pg_search_document).not_to be_present
end
# rubocop:enable RSpec/ExampleLength
# standard:enable RSpec/ExampleLength
end

context "via :unless" do
Expand All @@ -326,7 +326,7 @@ def foo
end
end

# rubocop:disable RSpec/ExampleLength
# standard:disable RSpec/ExampleLength
it "calls update_pg_search_document on each record" do
record_1 = Model.create!(inactive: true)
record_2 = Model.create!(inactive: false)
Expand All @@ -352,10 +352,10 @@ def foo
expect(record_1.pg_search_document).not_to be_present
expect(record_2.pg_search_document).to be_present
end
# rubocop:enable RSpec/ExampleLength
# standard:enable RSpec/ExampleLength
end
end
end
end
end
# rubocop:enable RSpec/NestedGroups
# standard:enable RSpec/NestedGroups
6 changes: 3 additions & 3 deletions spec/lib/pg_search/multisearch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "spec_helper"
require "active_support/core_ext/kernel/reporting"

# rubocop:disable RSpec/NestedGroups
# standard:disable RSpec/NestedGroups
describe PgSearch::Multisearch do
with_table "pg_search_documents", &DOCUMENTS_SCHEMA

Expand Down Expand Up @@ -135,7 +135,7 @@ def model.rebuild_pg_search_documents
end

describe "the generated SQL" do
let(:now) { Time.now }
let(:now) { Time.now } # standard:disable Rails/TimeZone

before { allow(Time).to receive(:now).and_return(now) }

Expand Down Expand Up @@ -195,4 +195,4 @@ def model.rebuild_pg_search_documents
end
end
end
# rubocop:enable RSpec/NestedGroups
# standard:enable RSpec/NestedGroups
Loading

0 comments on commit d179680

Please sign in to comment.