rubocop-trailblazer 0.1.0
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 +7 -0
- data/lib/rubocop/cop/minitest/variable_as_actual_argument.rb +32 -0
- data/lib/rubocop/cop/trailblazer_cops.rb +3 -0
- data/lib/rubocop/trailblazer/inject.rb +18 -0
- data/lib/rubocop/trailblazer/version.rb +7 -0
- data/lib/rubocop/trailblazer.rb +11 -0
- data/lib/rubocop-trailblazer.rb +12 -0
- metadata +93 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: 9baf0c0785abd0b96e2edcce56751ef2a2b124a0a4995d16452b038ad73e4ee4
         | 
| 4 | 
            +
              data.tar.gz: 80287fb65c32a9924855307d8f8ab59d2829d2308a7edbb3df61bebf97739b3e
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: a1f0c37d1516461865211e1e870563e2e4066aecb3e736d905a85ac1344c0431daf4729d56ffa2dddac714f5528593b2c3adbaee439f73fba68011b60f0a95c5
         | 
| 7 | 
            +
              data.tar.gz: 46b9cc5f9cc7add3430f0939eb545f215db8a64c1b497fbc80f697480d6e1dca60bf9eda77c88a51fa70965294eb0d91e62d252ebed6414057749361a267fd03
         | 
| @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module RuboCop
         | 
| 4 | 
            +
              module Cop
         | 
| 5 | 
            +
                module Minitest
         | 
| 6 | 
            +
                  # Checks for `assert_equal` method calls where the actual
         | 
| 7 | 
            +
                  # argument is a variable and the expected argument is a literal.
         | 
| 8 | 
            +
                  #
         | 
| 9 | 
            +
                  # @example
         | 
| 10 | 
            +
                  #   # bad
         | 
| 11 | 
            +
                  #   assert_equal 3, my_var
         | 
| 12 | 
            +
                  #
         | 
| 13 | 
            +
                  #   # good
         | 
| 14 | 
            +
                  #   assert_equal my_var, 3
         | 
| 15 | 
            +
                  class VariableAsActualArgument < LiteralAsActualArgument
         | 
| 16 | 
            +
                    MSG = 'Replace the literal with the second argument.'
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                    def on_send(node)
         | 
| 19 | 
            +
                      return unless node.method?(:assert_equal)
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                      actual, expected, _message = *node.arguments
         | 
| 22 | 
            +
                      return unless actual&.recursive_basic_literal?
         | 
| 23 | 
            +
                      return if expected.recursive_basic_literal?
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                      add_offense(all_arguments_range(node)) do |corrector|
         | 
| 26 | 
            +
                        autocorrect(corrector, node, expected, actual)
         | 
| 27 | 
            +
                      end
         | 
| 28 | 
            +
                    end
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
            end
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module RuboCop
         | 
| 4 | 
            +
              module Trailblazer
         | 
| 5 | 
            +
                # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
         | 
| 6 | 
            +
                # bit of our configuration.
         | 
| 7 | 
            +
                module Inject
         | 
| 8 | 
            +
                  def self.defaults!
         | 
| 9 | 
            +
                    path = CONFIG_DEFAULT.to_s
         | 
| 10 | 
            +
                    hash = ConfigLoader.send(:load_yaml_configuration, path)
         | 
| 11 | 
            +
                    config = Config.new(hash, path).tap(&:make_excludes_absolute)
         | 
| 12 | 
            +
                    puts "configuration from #{path}" if ConfigLoader.debug?
         | 
| 13 | 
            +
                    config = ConfigLoader.merge_with_default(config, path)
         | 
| 14 | 
            +
                    ConfigLoader.instance_variable_set(:@default_configuration, config)
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module RuboCop
         | 
| 4 | 
            +
              module Trailblazer
         | 
| 5 | 
            +
                PROJECT_ROOT   = Pathname.new(__dir__).parent.parent.expand_path.freeze
         | 
| 6 | 
            +
                CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
         | 
| 7 | 
            +
                CONFIG         = YAML.safe_load(CONFIG_DEFAULT.read).freeze
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
            end
         | 
| @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'rubocop'
         | 
| 4 | 
            +
            require 'rubocop-minitest'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            require_relative 'rubocop/trailblazer'
         | 
| 7 | 
            +
            require_relative 'rubocop/trailblazer/version'
         | 
| 8 | 
            +
            require_relative 'rubocop/trailblazer/inject'
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            RuboCop::Trailblazer::Inject.defaults!
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            require_relative 'rubocop/cop/trailblazer_cops'
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,93 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: rubocop-trailblazer
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Abdelkader Boudih
         | 
| 8 | 
            +
            autorequire:
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2024-01-09 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: rubocop
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ">="
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '1.39'
         | 
| 20 | 
            +
                - - "<"
         | 
| 21 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            +
                    version: '2.0'
         | 
| 23 | 
            +
              type: :runtime
         | 
| 24 | 
            +
              prerelease: false
         | 
| 25 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - ">="
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: '1.39'
         | 
| 30 | 
            +
                - - "<"
         | 
| 31 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            +
                    version: '2.0'
         | 
| 33 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 34 | 
            +
              name: rubocop-minitest
         | 
| 35 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 36 | 
            +
                requirements:
         | 
| 37 | 
            +
                - - ">="
         | 
| 38 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 39 | 
            +
                    version: 0.3.0
         | 
| 40 | 
            +
                - - "<"
         | 
| 41 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 42 | 
            +
                    version: '1.0'
         | 
| 43 | 
            +
              type: :runtime
         | 
| 44 | 
            +
              prerelease: false
         | 
| 45 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 46 | 
            +
                requirements:
         | 
| 47 | 
            +
                - - ">="
         | 
| 48 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 49 | 
            +
                    version: 0.3.0
         | 
| 50 | 
            +
                - - "<"
         | 
| 51 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 52 | 
            +
                    version: '1.0'
         | 
| 53 | 
            +
            description: Trailblazer Style Guide for RuboCop
         | 
| 54 | 
            +
            email:
         | 
| 55 | 
            +
            - terminale@gmail.com
         | 
| 56 | 
            +
            executables: []
         | 
| 57 | 
            +
            extensions: []
         | 
| 58 | 
            +
            extra_rdoc_files: []
         | 
| 59 | 
            +
            files:
         | 
| 60 | 
            +
            - lib/rubocop-trailblazer.rb
         | 
| 61 | 
            +
            - lib/rubocop/cop/minitest/variable_as_actual_argument.rb
         | 
| 62 | 
            +
            - lib/rubocop/cop/trailblazer_cops.rb
         | 
| 63 | 
            +
            - lib/rubocop/trailblazer.rb
         | 
| 64 | 
            +
            - lib/rubocop/trailblazer/inject.rb
         | 
| 65 | 
            +
            - lib/rubocop/trailblazer/version.rb
         | 
| 66 | 
            +
            homepage: https://github.com/seuros/rubocop-trailblazer
         | 
| 67 | 
            +
            licenses:
         | 
| 68 | 
            +
            - MIT
         | 
| 69 | 
            +
            metadata:
         | 
| 70 | 
            +
              homepage_uri: https://github.com/seuros/rubocop-trailblazer
         | 
| 71 | 
            +
              source_code_uri: https://github.com/seuros/rubocop-trailblazer
         | 
| 72 | 
            +
              changelog_uri: https://github.com/seuros/rubocop-trailblazer/blob/master/CHANGELOG.md
         | 
| 73 | 
            +
              rubygems_mfa_required: 'true'
         | 
| 74 | 
            +
            post_install_message:
         | 
| 75 | 
            +
            rdoc_options: []
         | 
| 76 | 
            +
            require_paths:
         | 
| 77 | 
            +
            - lib
         | 
| 78 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
              requirements:
         | 
| 80 | 
            +
              - - ">="
         | 
| 81 | 
            +
                - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                  version: 2.7.0
         | 
| 83 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 84 | 
            +
              requirements:
         | 
| 85 | 
            +
              - - ">="
         | 
| 86 | 
            +
                - !ruby/object:Gem::Version
         | 
| 87 | 
            +
                  version: '0'
         | 
| 88 | 
            +
            requirements: []
         | 
| 89 | 
            +
            rubygems_version: 3.2.33
         | 
| 90 | 
            +
            signing_key:
         | 
| 91 | 
            +
            specification_version: 4
         | 
| 92 | 
            +
            summary: Trailblazer Style Guide for RuboCop
         | 
| 93 | 
            +
            test_files: []
         |