mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	Allow constants to be in PascalCase (i.e. Log, SuperConstant)
closes #148
This commit is contained in:
		
							parent
							
								
									1a25583036
								
							
						
					
					
						commit
						478da94c20
					
				
					 2 changed files with 11 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -24,6 +24,8 @@ module Ameba
 | 
			
		|||
        def works(n : Int32)
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        Log = ::Log.for("db")
 | 
			
		||||
 | 
			
		||||
        a = 1
 | 
			
		||||
        myVar = 2
 | 
			
		||||
        m_var = 3
 | 
			
		||||
| 
						 | 
				
			
			@ -31,21 +33,21 @@ module Ameba
 | 
			
		|||
      subject.catch(s).should be_valid
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it_reports_constant "MyBadConstant=1", "MYBADCONSTANT"
 | 
			
		||||
    # it_reports_constant "MyBadConstant=1", "MYBADCONSTANT"
 | 
			
		||||
    it_reports_constant "Wrong_NAME=2", "WRONG_NAME"
 | 
			
		||||
    it_reports_constant "Wrong_Name=3", "WRONG_NAME"
 | 
			
		||||
 | 
			
		||||
    it "reports rule, pos and message" do
 | 
			
		||||
      s = Source.new %(
 | 
			
		||||
        Const = 1
 | 
			
		||||
        Const_Name = 1
 | 
			
		||||
      ), "source.cr"
 | 
			
		||||
      subject.catch(s).should_not be_valid
 | 
			
		||||
      issue = s.issues.first
 | 
			
		||||
      issue.rule.should_not be_nil
 | 
			
		||||
      issue.location.to_s.should eq "source.cr:1:1"
 | 
			
		||||
      issue.end_location.to_s.should eq "source.cr:1:5"
 | 
			
		||||
      issue.end_location.to_s.should eq "source.cr:1:10"
 | 
			
		||||
      issue.message.should eq(
 | 
			
		||||
        "Constant name should be screaming-cased: CONST, not Const"
 | 
			
		||||
        "Constant name should be screaming-cased: CONST_NAME, not Const_Name"
 | 
			
		||||
      )
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue