mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	Support named arguments in VerboseBlock#node_to_s
This commit is contained in:
		
							parent
							
								
									16743a756c
								
							
						
					
					
						commit
						a9d1b17deb
					
				
					 2 changed files with 75 additions and 14 deletions
				
			
		| 
						 | 
				
			
			@ -154,6 +154,44 @@ module Ameba::Rule::Style
 | 
			
		|||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "reports call args and named_args" do
 | 
			
		||||
      short_block_variants = {
 | 
			
		||||
        %|map(&.to_s.[start: 0.to_i64, count: 3]?)|,
 | 
			
		||||
        %|map(&.to_s.[0.to_i64, count: 3]?)|,
 | 
			
		||||
        %|map(&.to_s.[0.to_i64, 3]?)|,
 | 
			
		||||
        %|map(&.to_s.[start: 0.to_i64, count: 3]=("foo"))|,
 | 
			
		||||
        %|map(&.to_s.[0.to_i64, count: 3]=("foo"))|,
 | 
			
		||||
        %|map(&.to_s.[0.to_i64, 3]=("foo"))|,
 | 
			
		||||
        %|map(&.to_s.camelcase(lower: true))|,
 | 
			
		||||
        %|map(&.to_s.camelcase)|,
 | 
			
		||||
        %|map(&.to_s.gsub('_', '-'))|,
 | 
			
		||||
        %|map(&.in?(*{1, 2, 3}, **{foo: :bar}))|,
 | 
			
		||||
        %|map(&.in?(1, *foo, 3, **bar))|,
 | 
			
		||||
        %|join(separator: '.', &.to_s)|,
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      source = Source.new path: "source.cr", code: %(
 | 
			
		||||
        (1..3).map { |i| i.to_s[start: 0.to_i64, count: 3]? }
 | 
			
		||||
        (1..3).map { |i| i.to_s[0.to_i64, count: 3]? }
 | 
			
		||||
        (1..3).map { |i| i.to_s[0.to_i64, 3]? }
 | 
			
		||||
        (1..3).map { |i| i.to_s[start: 0.to_i64, count: 3] = "foo" }
 | 
			
		||||
        (1..3).map { |i| i.to_s[0.to_i64, count: 3] = "foo" }
 | 
			
		||||
        (1..3).map { |i| i.to_s[0.to_i64, 3] = "foo" }
 | 
			
		||||
        (1..3).map { |i| i.to_s.camelcase(lower: true) }
 | 
			
		||||
        (1..3).map { |i| i.to_s.camelcase }
 | 
			
		||||
        (1..3).map { |i| i.to_s.gsub('_', '-') }
 | 
			
		||||
        (1..3).map { |i| i.in?(*{1, 2, 3}, **{foo: :bar}) }
 | 
			
		||||
        (1..3).map { |i| i.in?(1, *foo, 3, **bar) }
 | 
			
		||||
        (1..3).join(separator: '.') { |i| i.to_s }
 | 
			
		||||
      )
 | 
			
		||||
      subject.catch(source).should_not be_valid
 | 
			
		||||
      source.issues.size.should eq(short_block_variants.size)
 | 
			
		||||
 | 
			
		||||
      source.issues.each_with_index do |issue, i|
 | 
			
		||||
        issue.message.should eq(VerboseBlock::MSG % short_block_variants[i])
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "reports rule, pos and message" do
 | 
			
		||||
      source = Source.new path: "source.cr", code: %(
 | 
			
		||||
        (1..3).any? { |i| i.odd? }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue