rubocop-discourse 2.2.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.github/workflows/ci.yml +0 -1
 - data/.gitignore +0 -2
 - data/config/default.yml +6 -0
 - data/lib/rubocop/cop/discourse/no_mocking_jobs.rb +25 -0
 - data/lib/rubocop/cop/discourse/time_eq_matcher.rb +2 -2
 - data/rubocop-discourse.gemspec +7 -5
 - data/rubocop-rspec.yml +6 -9
 - data/spec/lib/rubocop/cop/no_mocking_jobs_enqueue_spec.rb +35 -0
 - metadata +9 -7
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 50836476c0589b9ca8acc327ce038e96e0e2896ad1facad4c91d389205aaffca
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 42ed42e6fc27220ce081eb59855e72e5397c13aee5763c839777d7cd8172ea61
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 04e74b802d15a2d1c1b2de4e312748733ef1e586220aaf0769b1b9f6212c5fc1fa245c2f4213ec06ac0c2e3b78bfcc10a8ef26c1b84571cc54401c6e17b03531
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 30496a225a1d441fdfb83e824b7f9f004131616b703ee14e11b9a51f4d6e6509b2fc714abe775da026d9081e4f08e2a91b87be35f652386302557560518b1a47
         
     | 
    
        data/.github/workflows/ci.yml
    CHANGED
    
    
    
        data/.gitignore
    CHANGED
    
    
    
        data/config/default.yml
    CHANGED
    
    
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module RuboCop
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Cop
         
     | 
| 
      
 5 
     | 
    
         
            +
                module Discourse
         
     | 
| 
      
 6 
     | 
    
         
            +
                  class NoMockingJobs < Cop
         
     | 
| 
      
 7 
     | 
    
         
            +
                    MSG = "Use the test helpers provided by Sidekiq instead of mocking `Jobs.expects(:enqueue)`."
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                    def_node_matcher :mocking_jobs_enqueue?, <<~MATCHER
         
     | 
| 
      
 10 
     | 
    
         
            +
                    (send (const nil? :Jobs) :expects (:sym :enqueue))
         
     | 
| 
      
 11 
     | 
    
         
            +
                    MATCHER
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                    def_node_matcher :mocking_jobs_enqueue_in?, <<~MATCHER
         
     | 
| 
      
 14 
     | 
    
         
            +
                    (send (const nil? :Jobs) :expects (:sym :enqueue_in))
         
     | 
| 
      
 15 
     | 
    
         
            +
                    MATCHER
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                    def on_send(node)
         
     | 
| 
      
 18 
     | 
    
         
            +
                      if mocking_jobs_enqueue?(node) || mocking_jobs_enqueue_in?(node)
         
     | 
| 
      
 19 
     | 
    
         
            +
                        add_offense(node, message: MSG)
         
     | 
| 
      
 20 
     | 
    
         
            +
                      end
         
     | 
| 
      
 21 
     | 
    
         
            +
                    end
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -3,7 +3,7 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module RuboCop
         
     | 
| 
       4 
4 
     | 
    
         
             
              module Cop
         
     | 
| 
       5 
5 
     | 
    
         
             
                module Discourse
         
     | 
| 
       6 
     | 
    
         
            -
                  # Use ` 
     | 
| 
      
 6 
     | 
    
         
            +
                  # Use `eq_time` matcher with timestamps in specs.
         
     | 
| 
       7 
7 
     | 
    
         
             
                  #
         
     | 
| 
       8 
8 
     | 
    
         
             
                  # @example
         
     | 
| 
       9 
9 
     | 
    
         
             
                  #   # bad
         
     | 
| 
         @@ -12,7 +12,7 @@ module RuboCop 
     | 
|
| 
       12 
12 
     | 
    
         
             
                  #   # good
         
     | 
| 
       13 
13 
     | 
    
         
             
                  #   expect(user.created_at).to eq_time(Time.zone.now)
         
     | 
| 
       14 
14 
     | 
    
         
             
                  class TimeEqMatcher < Cop
         
     | 
| 
       15 
     | 
    
         
            -
                    MSG = "Use  
     | 
| 
      
 15 
     | 
    
         
            +
                    MSG = "Use eq_time when testing timestamps"
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                    def_node_matcher :using_eq_matcher_with_timestamp?, <<-MATCHER
         
     | 
| 
       18 
18 
     | 
    
         
             
                      (send
         
     | 
    
        data/rubocop-discourse.gemspec
    CHANGED
    
    | 
         @@ -2,15 +2,17 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       4 
4 
     | 
    
         
             
              s.name        = "rubocop-discourse"
         
     | 
| 
       5 
     | 
    
         
            -
              s.version     = "2. 
     | 
| 
      
 5 
     | 
    
         
            +
              s.version     = "2.4.1"
         
     | 
| 
       6 
6 
     | 
    
         
             
              s.summary     = "Custom rubocop cops used by Discourse"
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.authors     = ["David Taylor"]
         
     | 
| 
       8 
     | 
    
         
            -
              s. 
     | 
| 
       9 
     | 
    
         
            -
              s. 
     | 
| 
      
 8 
     | 
    
         
            +
              s.license     = "MIT"
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.homepage    = "https://github.com/discourse/rubocop-discourse"
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              s.files = `git ls-files`.split($/)
         
     | 
| 
       10 
12 
     | 
    
         
             
              s.require_paths = ["lib"]
         
     | 
| 
       11 
13 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
              s.add_runtime_dependency "rubocop", ">=  
     | 
| 
       13 
     | 
    
         
            -
              s.add_runtime_dependency "rubocop-rspec", ">=  
     | 
| 
      
 14 
     | 
    
         
            +
              s.add_runtime_dependency "rubocop", ">= 1.1.0"
         
     | 
| 
      
 15 
     | 
    
         
            +
              s.add_runtime_dependency "rubocop-rspec", ">= 2.0.0"
         
     | 
| 
       14 
16 
     | 
    
         | 
| 
       15 
17 
     | 
    
         
             
              s.add_development_dependency "rake", "~> 13.0"
         
     | 
| 
       16 
18 
     | 
    
         
             
              s.add_development_dependency "rspec"
         
     | 
    
        data/rubocop-rspec.yml
    CHANGED
    
    | 
         @@ -99,9 +99,6 @@ RSpec/InstanceSpy: 
     | 
|
| 
       99 
99 
     | 
    
         
             
            RSpec/InstanceVariable:
         
     | 
| 
       100 
100 
     | 
    
         
             
              Enabled: false # TODO
         
     | 
| 
       101 
101 
     | 
    
         | 
| 
       102 
     | 
    
         
            -
            RSpec/InvalidPredicateMatcher:
         
     | 
| 
       103 
     | 
    
         
            -
              Enabled: true
         
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
102 
     | 
    
         
             
            RSpec/ItBehavesLike:
         
     | 
| 
       106 
103 
     | 
    
         
             
              Enabled: true
         
     | 
| 
       107 
104 
     | 
    
         | 
| 
         @@ -192,20 +189,20 @@ RSpec/VoidExpect: 
     | 
|
| 
       192 
189 
     | 
    
         
             
            RSpec/Yield:
         
     | 
| 
       193 
190 
     | 
    
         
             
              Enabled: true
         
     | 
| 
       194 
191 
     | 
    
         | 
| 
       195 
     | 
    
         
            -
            Capybara/CurrentPathExpectation:
         
     | 
| 
      
 192 
     | 
    
         
            +
            RSpec/Capybara/CurrentPathExpectation:
         
     | 
| 
       196 
193 
     | 
    
         
             
              Enabled: true
         
     | 
| 
       197 
194 
     | 
    
         | 
| 
       198 
     | 
    
         
            -
            Capybara/FeatureMethods:
         
     | 
| 
      
 195 
     | 
    
         
            +
            RSpec/Capybara/FeatureMethods:
         
     | 
| 
       199 
196 
     | 
    
         
             
              Enabled: true
         
     | 
| 
       200 
197 
     | 
    
         | 
| 
       201 
     | 
    
         
            -
            FactoryBot/AttributeDefinedStatically:
         
     | 
| 
      
 198 
     | 
    
         
            +
            RSpec/FactoryBot/AttributeDefinedStatically:
         
     | 
| 
       202 
199 
     | 
    
         
             
              Enabled: true
         
     | 
| 
       203 
200 
     | 
    
         | 
| 
       204 
     | 
    
         
            -
            FactoryBot/CreateList:
         
     | 
| 
      
 201 
     | 
    
         
            +
            RSpec/FactoryBot/CreateList:
         
     | 
| 
       205 
202 
     | 
    
         
             
              Enabled: true
         
     | 
| 
       206 
203 
     | 
    
         | 
| 
       207 
     | 
    
         
            -
            FactoryBot/FactoryClassName:
         
     | 
| 
      
 204 
     | 
    
         
            +
            RSpec/FactoryBot/FactoryClassName:
         
     | 
| 
       208 
205 
     | 
    
         
             
              Enabled: true
         
     | 
| 
       209 
206 
     | 
    
         | 
| 
       210 
     | 
    
         
            -
            Rails/HttpStatus:
         
     | 
| 
      
 207 
     | 
    
         
            +
            RSpec/Rails/HttpStatus:
         
     | 
| 
       211 
208 
     | 
    
         
             
              Enabled: true
         
     | 
| 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            describe RuboCop::Cop::Discourse::NoMockingJobs, :config do
         
     | 
| 
      
 6 
     | 
    
         
            +
              subject(:cop) { described_class.new(config) }
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              let(:config) do
         
     | 
| 
      
 9 
     | 
    
         
            +
                RuboCop::Config.new
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              it "raises an offense if Jobs is mocked with :enqueue" do
         
     | 
| 
      
 13 
     | 
    
         
            +
                inspect_source(<<~RUBY)
         
     | 
| 
      
 14 
     | 
    
         
            +
                Jobs.expects(:enqueue)
         
     | 
| 
      
 15 
     | 
    
         
            +
                RUBY
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                expect(cop.offenses.first.message).to eq(described_class::MSG)
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              it "raises an offense if Jobs is mocked with :enqueue_in" do
         
     | 
| 
      
 21 
     | 
    
         
            +
                inspect_source(<<~RUBY)
         
     | 
| 
      
 22 
     | 
    
         
            +
                Jobs.expects(:enqueue_in)
         
     | 
| 
      
 23 
     | 
    
         
            +
                RUBY
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                expect(cop.offenses.first.message).to eq(described_class::MSG)
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              it "does not raise an offense if Jobs is not mocked with :enqueue or :enqueue_in" do
         
     | 
| 
      
 29 
     | 
    
         
            +
                inspect_source(<<~RUBY)
         
     | 
| 
      
 30 
     | 
    
         
            +
                Jobs.enqueue(:some_job)
         
     | 
| 
      
 31 
     | 
    
         
            +
                RUBY
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                expect(cop.offenses).to eq([])
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: rubocop-discourse
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.4.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - David Taylor
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2020-06 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2020-11-06 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rubocop
         
     | 
| 
         @@ -16,28 +16,28 @@ dependencies: 
     | 
|
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
17 
     | 
    
         
             
                - - ">="
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version:  
     | 
| 
      
 19 
     | 
    
         
            +
                    version: 1.1.0
         
     | 
| 
       20 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       21 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       24 
24 
     | 
    
         
             
                - - ">="
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
     | 
    
         
            -
                    version:  
     | 
| 
      
 26 
     | 
    
         
            +
                    version: 1.1.0
         
     | 
| 
       27 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
28 
     | 
    
         
             
              name: rubocop-rspec
         
     | 
| 
       29 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
31 
     | 
    
         
             
                - - ">="
         
     | 
| 
       32 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version:  
     | 
| 
      
 33 
     | 
    
         
            +
                    version: 2.0.0
         
     | 
| 
       34 
34 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       35 
35 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       36 
36 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       37 
37 
     | 
    
         
             
                requirements:
         
     | 
| 
       38 
38 
     | 
    
         
             
                - - ">="
         
     | 
| 
       39 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
     | 
    
         
            -
                    version:  
     | 
| 
      
 40 
     | 
    
         
            +
                    version: 2.0.0
         
     | 
| 
       41 
41 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
42 
     | 
    
         
             
              name: rake
         
     | 
| 
       43 
43 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -86,6 +86,7 @@ files: 
     | 
|
| 
       86 
86 
     | 
    
         
             
            - lib/rubocop/cop/discourse/no_chdir.rb
         
     | 
| 
       87 
87 
     | 
    
         
             
            - lib/rubocop/cop/discourse/no_direct_multisite_manipulation.rb
         
     | 
| 
       88 
88 
     | 
    
         
             
            - lib/rubocop/cop/discourse/no_json_parse_response.rb
         
     | 
| 
      
 89 
     | 
    
         
            +
            - lib/rubocop/cop/discourse/no_mocking_jobs.rb
         
     | 
| 
       89 
90 
     | 
    
         
             
            - lib/rubocop/cop/discourse/no_nokogiri_html_fragment.rb
         
     | 
| 
       90 
91 
     | 
    
         
             
            - lib/rubocop/cop/discourse/no_reset_column_information_in_migrations.rb
         
     | 
| 
       91 
92 
     | 
    
         
             
            - lib/rubocop/cop/discourse/no_time_new_without_args.rb
         
     | 
| 
         @@ -98,9 +99,10 @@ files: 
     | 
|
| 
       98 
99 
     | 
    
         
             
            - rubocop-discourse.gemspec
         
     | 
| 
       99 
100 
     | 
    
         
             
            - rubocop-rspec.yml
         
     | 
| 
       100 
101 
     | 
    
         
             
            - spec/lib/rubocop/cop/no_add_reference_active_record_migrations_spec.rb
         
     | 
| 
      
 102 
     | 
    
         
            +
            - spec/lib/rubocop/cop/no_mocking_jobs_enqueue_spec.rb
         
     | 
| 
       101 
103 
     | 
    
         
             
            - spec/lib/rubocop/cop/no_reset_column_information_migrations_spec.rb
         
     | 
| 
       102 
104 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       103 
     | 
    
         
            -
            homepage: 
         
     | 
| 
      
 105 
     | 
    
         
            +
            homepage: https://github.com/discourse/rubocop-discourse
         
     | 
| 
       104 
106 
     | 
    
         
             
            licenses:
         
     | 
| 
       105 
107 
     | 
    
         
             
            - MIT
         
     | 
| 
       106 
108 
     | 
    
         
             
            metadata: {}
         
     |