rubocop-on-rbs 0.6.0 → 0.8.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 +4 -4
 - data/CHANGELOG.md +9 -0
 - data/config/default.yml +10 -4
 - data/lib/rubocop/cop/rbs/lint/ambiguous_operator_precedence.rb +69 -0
 - data/lib/rubocop/cop/rbs/lint/useless_access_modifier.rb +95 -0
 - data/lib/rubocop/cop/rbs/lint/useless_overload_type_params.rb +12 -4
 - data/lib/rubocop/cop/rbs/style/redundant_parentheses.rb +12 -1
 - data/lib/rubocop/cop/rbs_cops.rb +3 -1
 - data/lib/rubocop/rbs/processed_rbs_source.rb +4 -2
 - data/lib/rubocop/rbs/version.rb +1 -1
 - metadata +7 -5
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 4d260d64881cb68a460632386ff5707ab99717fd56b2ac7ff1824a1cbc55680e
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 353ef7d2b3b583d65880995d4eac7e72cca2f591953a747a826a2c0e55152601
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a77a462af68842c31f3cea245770215819515062faeaf24b6ef5f2d9c87ba0544dbf07f9cd6abc728955d4a67b77fa595baaad3e92c2f3fa7bfb780954a9018b
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 496f22af11da44e34c72c558738a86f1eda45c3afeba5b629d893cf2be6f665b3f477bc8189e32d78e49d5da49e2ce868ce6ab87f4b2652fc4e80fca71764dc4
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,5 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ## [Unreleased]
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            ## [0.7.0] - 2024-06-27
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            * Add RBS/Lint/AmbiguousOperatorPrecedence by @ksss in https://github.com/ksss/rubocop-on-rbs/pull/22
         
     | 
| 
      
 6 
     | 
    
         
            +
            * Add RBS/Lint/UselessAccessModifier by @ksss in https://github.com/ksss/rubocop-on-rbs/pull/23
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            ## [0.6.0] - 2024-06-18
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            * Fixed problems interfering with other Cop by @ksss in https://github.com/ksss/rubocop-on-rbs/pull/20
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       3 
12 
     | 
    
         
             
            ## [0.5.0] - 2024-06-17
         
     | 
| 
       4 
13 
     | 
    
         | 
| 
       5 
14 
     | 
    
         
             
            * Fix destructive change by @ksss in https://github.com/ksss/rubocop-on-rbs/pull/17
         
     | 
    
        data/config/default.yml
    CHANGED
    
    | 
         @@ -78,15 +78,18 @@ RBS/Layout/TrailingWhitespace: 
     | 
|
| 
       78 
78 
     | 
    
         
             
            ## RBS/Lint
         
     | 
| 
       79 
79 
     | 
    
         | 
| 
       80 
80 
     | 
    
         
             
            RBS/Lint:
         
     | 
| 
      
 81 
     | 
    
         
            +
              Severity: warning
         
     | 
| 
      
 82 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
            RBS/Lint/AmbiguousOperatorPrecedence:
         
     | 
| 
      
 85 
     | 
    
         
            +
              Description: 'Check ambiguous operator precedence'
         
     | 
| 
       81 
86 
     | 
    
         
             
              Enabled: true
         
     | 
| 
       82 
87 
     | 
    
         | 
| 
       83 
88 
     | 
    
         
             
            RBS/Lint/DuplicateOverload:
         
     | 
| 
       84 
     | 
    
         
            -
              Severity: warning
         
     | 
| 
       85 
89 
     | 
    
         
             
              Description: 'Checks that there are no repeated overload bodies'
         
     | 
| 
       86 
90 
     | 
    
         
             
              Enabled: true
         
     | 
| 
       87 
91 
     | 
    
         | 
| 
       88 
92 
     | 
    
         
             
            RBS/Lint/LiteralIntersection:
         
     | 
| 
       89 
     | 
    
         
            -
              Severity: warning
         
     | 
| 
       90 
93 
     | 
    
         
             
              Description: 'Check literal intersection'
         
     | 
| 
       91 
94 
     | 
    
         
             
              Enabled: true
         
     | 
| 
       92 
95 
     | 
    
         | 
| 
         @@ -95,13 +98,16 @@ RBS/Lint/Syntax: 
     | 
|
| 
       95 
98 
     | 
    
         
             
              Description: 'Check RBS syntax'
         
     | 
| 
       96 
99 
     | 
    
         
             
              Enabled: true
         
     | 
| 
       97 
100 
     | 
    
         | 
| 
      
 101 
     | 
    
         
            +
            RBS/Lint/UselessAccessModifier:
         
     | 
| 
      
 102 
     | 
    
         
            +
              AutoCorrect: contextual
         
     | 
| 
      
 103 
     | 
    
         
            +
              Description: 'Check useless access modifier'
         
     | 
| 
      
 104 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
       98 
106 
     | 
    
         
             
            RBS/Lint/UselessOverloadTypeParams:
         
     | 
| 
       99 
     | 
    
         
            -
              Severity: warning
         
     | 
| 
       100 
107 
     | 
    
         
             
              Description: 'Check redundant overload type params'
         
     | 
| 
       101 
108 
     | 
    
         
             
              Enabled: true
         
     | 
| 
       102 
109 
     | 
    
         | 
| 
       103 
110 
     | 
    
         
             
            RBS/Lint/WillSyntaxError:
         
     | 
| 
       104 
     | 
    
         
            -
              Severity: warning
         
     | 
| 
       105 
111 
     | 
    
         
             
              Description: 'Check RBS will syntax error'
         
     | 
| 
       106 
112 
     | 
    
         
             
              Enabled: true
         
     | 
| 
       107 
113 
     | 
    
         | 
| 
         @@ -0,0 +1,69 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module RuboCop
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Cop
         
     | 
| 
      
 5 
     | 
    
         
            +
                module RBS
         
     | 
| 
      
 6 
     | 
    
         
            +
                  module Lint
         
     | 
| 
      
 7 
     | 
    
         
            +
                    # Checks that there are no repeated overload bodies
         
     | 
| 
      
 8 
     | 
    
         
            +
                    #
         
     | 
| 
      
 9 
     | 
    
         
            +
                    # @example default
         
     | 
| 
      
 10 
     | 
    
         
            +
                    #   # bad
         
     | 
| 
      
 11 
     | 
    
         
            +
                    #   def foo: (A | B & C) -> void
         
     | 
| 
      
 12 
     | 
    
         
            +
                    #
         
     | 
| 
      
 13 
     | 
    
         
            +
                    #   # good
         
     | 
| 
      
 14 
     | 
    
         
            +
                    #   def foo: (A | (B & C)) -> void
         
     | 
| 
      
 15 
     | 
    
         
            +
                    #
         
     | 
| 
      
 16 
     | 
    
         
            +
                    class AmbiguousOperatorPrecedence < RuboCop::RBS::CopBase
         
     | 
| 
      
 17 
     | 
    
         
            +
                      MSG = 'Wrap expressions with varying precedence with parentheses to avoid ambiguity.'
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                      extend AutoCorrector
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                      def on_rbs_def(decl)
         
     | 
| 
      
 22 
     | 
    
         
            +
                        decl.overloads.each do |overload|
         
     | 
| 
      
 23 
     | 
    
         
            +
                          overload.method_type.each_type do |type|
         
     | 
| 
      
 24 
     | 
    
         
            +
                            check_type(type)
         
     | 
| 
      
 25 
     | 
    
         
            +
                          end
         
     | 
| 
      
 26 
     | 
    
         
            +
                        end
         
     | 
| 
      
 27 
     | 
    
         
            +
                      end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                      def on_rbs_constant(const)
         
     | 
| 
      
 30 
     | 
    
         
            +
                        check_type(const.type)
         
     | 
| 
      
 31 
     | 
    
         
            +
                      end
         
     | 
| 
      
 32 
     | 
    
         
            +
                      alias on_rbs_global on_rbs_constant
         
     | 
| 
      
 33 
     | 
    
         
            +
                      alias on_rbs_type_alias on_rbs_constant
         
     | 
| 
      
 34 
     | 
    
         
            +
                      alias on_rbs_attribute on_rbs_constant
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                      def check_type(type)
         
     | 
| 
      
 37 
     | 
    
         
            +
                        on_type([::RBS::Types::Union], type) do |union|
         
     | 
| 
      
 38 
     | 
    
         
            +
                          union.types.each do |t|
         
     | 
| 
      
 39 
     | 
    
         
            +
                            case t
         
     | 
| 
      
 40 
     | 
    
         
            +
                            when ::RBS::Types::Intersection
         
     | 
| 
      
 41 
     | 
    
         
            +
                              next unless t.location
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                              start_index = bsearch_token_index(t.location.start_pos)
         
     | 
| 
      
 44 
     | 
    
         
            +
                              end_index = bsearch_token_index(t.location.end_pos)
         
     | 
| 
      
 45 
     | 
    
         
            +
                              before = processed_rbs_source.tokens[start_index - 1]
         
     | 
| 
      
 46 
     | 
    
         
            +
                              after = processed_rbs_source.tokens[end_index]
         
     | 
| 
      
 47 
     | 
    
         
            +
                              unless before.type == :pLPAREN && after.type == :pRPAREN
         
     | 
| 
      
 48 
     | 
    
         
            +
                                range = location_to_range(t.location)
         
     | 
| 
      
 49 
     | 
    
         
            +
                                add_offense(range) do |corrector|
         
     | 
| 
      
 50 
     | 
    
         
            +
                                  corrector.wrap(range, '(', ')')
         
     | 
| 
      
 51 
     | 
    
         
            +
                                end
         
     | 
| 
      
 52 
     | 
    
         
            +
                              end
         
     | 
| 
      
 53 
     | 
    
         
            +
                            end
         
     | 
| 
      
 54 
     | 
    
         
            +
                          end
         
     | 
| 
      
 55 
     | 
    
         
            +
                        end
         
     | 
| 
      
 56 
     | 
    
         
            +
                      end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                      private
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                      def bsearch_token_index(pos)
         
     | 
| 
      
 61 
     | 
    
         
            +
                        processed_rbs_source.tokens.bsearch_index do |token|
         
     | 
| 
      
 62 
     | 
    
         
            +
                          token.location.start_pos >= pos
         
     | 
| 
      
 63 
     | 
    
         
            +
                        end or raise
         
     | 
| 
      
 64 
     | 
    
         
            +
                      end
         
     | 
| 
      
 65 
     | 
    
         
            +
                    end
         
     | 
| 
      
 66 
     | 
    
         
            +
                  end
         
     | 
| 
      
 67 
     | 
    
         
            +
                end
         
     | 
| 
      
 68 
     | 
    
         
            +
              end
         
     | 
| 
      
 69 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,95 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module RuboCop
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Cop
         
     | 
| 
      
 5 
     | 
    
         
            +
                module RBS
         
     | 
| 
      
 6 
     | 
    
         
            +
                  module Lint
         
     | 
| 
      
 7 
     | 
    
         
            +
                    # @example default
         
     | 
| 
      
 8 
     | 
    
         
            +
                    #   # bad
         
     | 
| 
      
 9 
     | 
    
         
            +
                    #   class Foo
         
     | 
| 
      
 10 
     | 
    
         
            +
                    #     public # this is redundant (default access is public)
         
     | 
| 
      
 11 
     | 
    
         
            +
                    #
         
     | 
| 
      
 12 
     | 
    
         
            +
                    #     def method: () -> void
         
     | 
| 
      
 13 
     | 
    
         
            +
                    #   end
         
     | 
| 
      
 14 
     | 
    
         
            +
                    #
         
     | 
| 
      
 15 
     | 
    
         
            +
                    #   # bad
         
     | 
| 
      
 16 
     | 
    
         
            +
                    #   class Foo
         
     | 
| 
      
 17 
     | 
    
         
            +
                    #     # The following is redundant (methods defined on the class'
         
     | 
| 
      
 18 
     | 
    
         
            +
                    #     # singleton class are not affected by the private modifier)
         
     | 
| 
      
 19 
     | 
    
         
            +
                    #     private
         
     | 
| 
      
 20 
     | 
    
         
            +
                    #
         
     | 
| 
      
 21 
     | 
    
         
            +
                    #     def self.method3: () -> void
         
     | 
| 
      
 22 
     | 
    
         
            +
                    #   end
         
     | 
| 
      
 23 
     | 
    
         
            +
                    #
         
     | 
| 
      
 24 
     | 
    
         
            +
                    #   # bad
         
     | 
| 
      
 25 
     | 
    
         
            +
                    #   class Foo
         
     | 
| 
      
 26 
     | 
    
         
            +
                    #     private # this is redundant (no following methods are defined)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    #   end
         
     | 
| 
      
 28 
     | 
    
         
            +
                    #
         
     | 
| 
      
 29 
     | 
    
         
            +
                    #   # good
         
     | 
| 
      
 30 
     | 
    
         
            +
                    #   class Foo
         
     | 
| 
      
 31 
     | 
    
         
            +
                    #     private # this is not redundant (a method is defined)
         
     | 
| 
      
 32 
     | 
    
         
            +
                    #
         
     | 
| 
      
 33 
     | 
    
         
            +
                    #     def method2
         
     | 
| 
      
 34 
     | 
    
         
            +
                    #     end
         
     | 
| 
      
 35 
     | 
    
         
            +
                    #   end
         
     | 
| 
      
 36 
     | 
    
         
            +
                    #
         
     | 
| 
      
 37 
     | 
    
         
            +
                    class UselessAccessModifier < RuboCop::RBS::CopBase
         
     | 
| 
      
 38 
     | 
    
         
            +
                      extend AutoCorrector
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                      MSG = 'Useless `%<current>s` access modifier.'
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                      def on_rbs_class(decl)
         
     | 
| 
      
 43 
     | 
    
         
            +
                        current = nil
         
     | 
| 
      
 44 
     | 
    
         
            +
                        unused = true
         
     | 
| 
      
 45 
     | 
    
         
            +
                        decl.members.each do |member|
         
     | 
| 
      
 46 
     | 
    
         
            +
                          next unless member.location
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                          case member
         
     | 
| 
      
 49 
     | 
    
         
            +
                          when ::RBS::AST::Members::Public
         
     | 
| 
      
 50 
     | 
    
         
            +
                            if current.nil? || current.is_a?(::RBS::AST::Members::Public)
         
     | 
| 
      
 51 
     | 
    
         
            +
                              range = location_to_range(member.location)
         
     | 
| 
      
 52 
     | 
    
         
            +
                              add_offense(range, message: format(MSG, { current: 'public' })) do |corrector|
         
     | 
| 
      
 53 
     | 
    
         
            +
                                autocorrect(corrector, range)
         
     | 
| 
      
 54 
     | 
    
         
            +
                              end
         
     | 
| 
      
 55 
     | 
    
         
            +
                            end
         
     | 
| 
      
 56 
     | 
    
         
            +
                            current = member
         
     | 
| 
      
 57 
     | 
    
         
            +
                          when ::RBS::AST::Members::Private
         
     | 
| 
      
 58 
     | 
    
         
            +
                            if current.is_a?(::RBS::AST::Members::Private)
         
     | 
| 
      
 59 
     | 
    
         
            +
                              range = location_to_range(member.location)
         
     | 
| 
      
 60 
     | 
    
         
            +
                              add_offense(range, message: format(MSG, { current: 'private' })) do |corrector|
         
     | 
| 
      
 61 
     | 
    
         
            +
                                autocorrect(corrector, range)
         
     | 
| 
      
 62 
     | 
    
         
            +
                              end
         
     | 
| 
      
 63 
     | 
    
         
            +
                            end
         
     | 
| 
      
 64 
     | 
    
         
            +
                            current = member
         
     | 
| 
      
 65 
     | 
    
         
            +
                          when ::RBS::AST::Members::MethodDefinition
         
     | 
| 
      
 66 
     | 
    
         
            +
                            if member.kind != :singleton
         
     | 
| 
      
 67 
     | 
    
         
            +
                              unused = false
         
     | 
| 
      
 68 
     | 
    
         
            +
                            end
         
     | 
| 
      
 69 
     | 
    
         
            +
                          end
         
     | 
| 
      
 70 
     | 
    
         
            +
                        end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                        if unused && current
         
     | 
| 
      
 73 
     | 
    
         
            +
                          range = location_to_range(current.location)
         
     | 
| 
      
 74 
     | 
    
         
            +
                          vis = case current
         
     | 
| 
      
 75 
     | 
    
         
            +
                                when ::RBS::AST::Members::Public
         
     | 
| 
      
 76 
     | 
    
         
            +
                                  'public'
         
     | 
| 
      
 77 
     | 
    
         
            +
                                when ::RBS::AST::Members::Private
         
     | 
| 
      
 78 
     | 
    
         
            +
                                  'private'
         
     | 
| 
      
 79 
     | 
    
         
            +
                                end
         
     | 
| 
      
 80 
     | 
    
         
            +
                          add_offense(range, message: format(MSG, { current: vis })) do |corrector|
         
     | 
| 
      
 81 
     | 
    
         
            +
                            autocorrect(corrector, range)
         
     | 
| 
      
 82 
     | 
    
         
            +
                          end
         
     | 
| 
      
 83 
     | 
    
         
            +
                        end
         
     | 
| 
      
 84 
     | 
    
         
            +
                      end
         
     | 
| 
      
 85 
     | 
    
         
            +
                      alias on_rbs_module on_rbs_class
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                      def autocorrect(corrector, range)
         
     | 
| 
      
 88 
     | 
    
         
            +
                        line = range_by_whole_lines(range, include_final_newline: true)
         
     | 
| 
      
 89 
     | 
    
         
            +
                        corrector.remove(line)
         
     | 
| 
      
 90 
     | 
    
         
            +
                      end
         
     | 
| 
      
 91 
     | 
    
         
            +
                    end
         
     | 
| 
      
 92 
     | 
    
         
            +
                  end
         
     | 
| 
      
 93 
     | 
    
         
            +
                end
         
     | 
| 
      
 94 
     | 
    
         
            +
              end
         
     | 
| 
      
 95 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -20,19 +20,27 @@ module RuboCop 
     | 
|
| 
       20 
20 
     | 
    
         
             
                          next if overload.method_type.type_params.empty?
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
                          type_params = overload.method_type.type_params.dup
         
     | 
| 
      
 23 
     | 
    
         
            +
                          map = type_params.to_h { |param| [param.name, param] }
         
     | 
| 
      
 24 
     | 
    
         
            +
                          type_params.each do |type_param|
         
     | 
| 
      
 25 
     | 
    
         
            +
                            if type_param.upper_bound
         
     | 
| 
      
 26 
     | 
    
         
            +
                              used_variable_in_type(type_param.upper_bound) do |var|
         
     | 
| 
      
 27 
     | 
    
         
            +
                                map.delete(var.name)
         
     | 
| 
      
 28 
     | 
    
         
            +
                              end
         
     | 
| 
      
 29 
     | 
    
         
            +
                            end
         
     | 
| 
      
 30 
     | 
    
         
            +
                          end
         
     | 
| 
       23 
31 
     | 
    
         | 
| 
       24 
32 
     | 
    
         
             
                          overload.method_type.each_type do |type|
         
     | 
| 
       25 
33 
     | 
    
         
             
                            used_variable_in_type(type) do |var|
         
     | 
| 
       26 
     | 
    
         
            -
                               
     | 
| 
      
 34 
     | 
    
         
            +
                              map.delete(var.name)
         
     | 
| 
       27 
35 
     | 
    
         
             
                            end
         
     | 
| 
       28 
36 
     | 
    
         
             
                          end
         
     | 
| 
       29 
     | 
    
         
            -
                          next if  
     | 
| 
      
 37 
     | 
    
         
            +
                          next if map.empty?
         
     | 
| 
       30 
38 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
                           
     | 
| 
      
 39 
     | 
    
         
            +
                          map.each do |name, type_param|
         
     | 
| 
       32 
40 
     | 
    
         
             
                            next unless type_param.location
         
     | 
| 
       33 
41 
     | 
    
         | 
| 
       34 
42 
     | 
    
         
             
                            t = location_to_range(type_param.location[:name])
         
     | 
| 
       35 
     | 
    
         
            -
                            add_offense(t, message: format(MSG, variable:  
     | 
| 
      
 43 
     | 
    
         
            +
                            add_offense(t, message: format(MSG, variable: name))
         
     | 
| 
       36 
44 
     | 
    
         
             
                          end
         
     | 
| 
       37 
45 
     | 
    
         
             
                        end
         
     | 
| 
       38 
46 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -72,9 +72,20 @@ module RuboCop 
     | 
|
| 
       72 
72 
     | 
    
         
             
                          excludes = [
         
     | 
| 
       73 
73 
     | 
    
         
             
                            ::RBS::Types::Union,
         
     | 
| 
       74 
74 
     | 
    
         
             
                            ::RBS::Types::Intersection,
         
     | 
| 
       75 
     | 
    
         
            -
                            ::RBS::Types::Proc
         
     | 
| 
      
 75 
     | 
    
         
            +
                            ::RBS::Types::Proc,
         
     | 
| 
       76 
76 
     | 
    
         
             
                          ]
         
     | 
| 
       77 
77 
     | 
    
         
             
                          @cop.on_not_type(excludes, @type) do |type|
         
     | 
| 
      
 78 
     | 
    
         
            +
                            case type
         
     | 
| 
      
 79 
     | 
    
         
            +
                            when ::RBS::Types::Optional
         
     | 
| 
      
 80 
     | 
    
         
            +
                              case type.type
         
     | 
| 
      
 81 
     | 
    
         
            +
                              when ::RBS::Types::Literal
         
     | 
| 
      
 82 
     | 
    
         
            +
                                case type.type.literal
         
     | 
| 
      
 83 
     | 
    
         
            +
                                when Symbol
         
     | 
| 
      
 84 
     | 
    
         
            +
                                  # Skip optional with symbol literal (e.g. `(:sym)?`)
         
     | 
| 
      
 85 
     | 
    
         
            +
                                  @skip << type.location.start_pos
         
     | 
| 
      
 86 
     | 
    
         
            +
                                end
         
     | 
| 
      
 87 
     | 
    
         
            +
                              end
         
     | 
| 
      
 88 
     | 
    
         
            +
                            end
         
     | 
| 
       78 
89 
     | 
    
         
             
                            check_parentheses(type)
         
     | 
| 
       79 
90 
     | 
    
         
             
                          end
         
     | 
| 
       80 
91 
     | 
    
         
             
                        end
         
     | 
    
        data/lib/rubocop/cop/rbs_cops.rb
    CHANGED
    
    | 
         @@ -15,10 +15,12 @@ require_relative 'rbs/layout/space_before_colon' 
     | 
|
| 
       15 
15 
     | 
    
         
             
            require_relative 'rbs/layout/space_before_overload'
         
     | 
| 
       16 
16 
     | 
    
         
             
            require_relative 'rbs/layout/trailing_whitespace'
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
      
 18 
     | 
    
         
            +
            require_relative 'rbs/lint/ambiguous_operator_precedence'
         
     | 
| 
       18 
19 
     | 
    
         
             
            require_relative 'rbs/lint/duplicate_overload'
         
     | 
| 
       19 
20 
     | 
    
         
             
            require_relative 'rbs/lint/literal_intersection'
         
     | 
| 
       20 
     | 
    
         
            -
            require_relative 'rbs/lint/useless_overload_type_params'
         
     | 
| 
       21 
21 
     | 
    
         
             
            require_relative 'rbs/lint/syntax'
         
     | 
| 
      
 22 
     | 
    
         
            +
            require_relative 'rbs/lint/useless_access_modifier'
         
     | 
| 
      
 23 
     | 
    
         
            +
            require_relative 'rbs/lint/useless_overload_type_params'
         
     | 
| 
       22 
24 
     | 
    
         
             
            require_relative 'rbs/lint/will_syntax_error'
         
     | 
| 
       23 
25 
     | 
    
         | 
| 
       24 
26 
     | 
    
         
             
            require_relative 'rbs/style/block_return_boolish'
         
     | 
| 
         @@ -23,9 +23,11 @@ module RuboCop 
     | 
|
| 
       23 
23 
     | 
    
         
             
                    @error.nil?
         
     | 
| 
       24 
24 
     | 
    
         
             
                  end
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
                  def tokens
         
     | 
| 
      
 26 
     | 
    
         
            +
                  def tokens(with_trivia: false)
         
     | 
| 
       27 
27 
     | 
    
         
             
                    @tokens ||= begin
         
     | 
| 
       28 
     | 
    
         
            -
                      ::RBS::Parser.lex(buffer).value
         
     | 
| 
      
 28 
     | 
    
         
            +
                      tokens = ::RBS::Parser.lex(buffer).value
         
     | 
| 
      
 29 
     | 
    
         
            +
                      tokens.reject! { |token| token.type == :tTRIVIA } unless with_trivia
         
     | 
| 
      
 30 
     | 
    
         
            +
                      tokens
         
     | 
| 
       29 
31 
     | 
    
         
             
                    end
         
     | 
| 
       30 
32 
     | 
    
         
             
                  end
         
     | 
| 
       31 
33 
     | 
    
         
             
                end
         
     | 
    
        data/lib/rubocop/rbs/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: rubocop-on-rbs
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.8.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - ksss
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2024-06 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2024-08-06 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rbs
         
     | 
| 
         @@ -30,14 +30,14 @@ dependencies: 
     | 
|
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
31 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       32 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version: '1. 
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '1.61'
         
     | 
| 
       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: '1. 
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '1.61'
         
     | 
| 
       41 
41 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
42 
     | 
    
         
             
              name: zlib
         
     | 
| 
       43 
43 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -77,9 +77,11 @@ files: 
     | 
|
| 
       77 
77 
     | 
    
         
             
            - lib/rubocop/cop/rbs/layout/space_before_colon.rb
         
     | 
| 
       78 
78 
     | 
    
         
             
            - lib/rubocop/cop/rbs/layout/space_before_overload.rb
         
     | 
| 
       79 
79 
     | 
    
         
             
            - lib/rubocop/cop/rbs/layout/trailing_whitespace.rb
         
     | 
| 
      
 80 
     | 
    
         
            +
            - lib/rubocop/cop/rbs/lint/ambiguous_operator_precedence.rb
         
     | 
| 
       80 
81 
     | 
    
         
             
            - lib/rubocop/cop/rbs/lint/duplicate_overload.rb
         
     | 
| 
       81 
82 
     | 
    
         
             
            - lib/rubocop/cop/rbs/lint/literal_intersection.rb
         
     | 
| 
       82 
83 
     | 
    
         
             
            - lib/rubocop/cop/rbs/lint/syntax.rb
         
     | 
| 
      
 84 
     | 
    
         
            +
            - lib/rubocop/cop/rbs/lint/useless_access_modifier.rb
         
     | 
| 
       83 
85 
     | 
    
         
             
            - lib/rubocop/cop/rbs/lint/useless_overload_type_params.rb
         
     | 
| 
       84 
86 
     | 
    
         
             
            - lib/rubocop/cop/rbs/lint/will_syntax_error.rb
         
     | 
| 
       85 
87 
     | 
    
         
             
            - lib/rubocop/cop/rbs/style/block_return_boolish.rb
         
     | 
| 
         @@ -120,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       120 
122 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       121 
123 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       122 
124 
     | 
    
         
             
            requirements: []
         
     | 
| 
       123 
     | 
    
         
            -
            rubygems_version: 3.5. 
     | 
| 
      
 125 
     | 
    
         
            +
            rubygems_version: 3.5.11
         
     | 
| 
       124 
126 
     | 
    
         
             
            signing_key:
         
     | 
| 
       125 
127 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       126 
128 
     | 
    
         
             
            summary: RuboCop extension for RBS file.
         
     |