struct Ameba::Rule::Lint::UselessConditionInWhen
- Ameba::Rule::Lint::UselessConditionInWhen
- Ameba::Rule::Base
- Struct
- Value
- Object
Overview
A rule that disallows useless conditions in when clause where it is guaranteed to always return the same result.
For example, this is considered invalid:
case
when utc?
  io << " UTC"
when local?
  Format.new(" %:z").format(self, io) if local?
endAnd has to be written as the following:
case
when utc?
  io << " UTC"
when local?
  Format.new(" %:z").format(self, io)
endYAML configuration example:
Lint/UselessConditionInWhen:
  Enabled: trueDefined in:
ameba/rule/lint/useless_condition_in_when.crConstant Summary
- 
        MSG = "Useless condition in when detected"
Constructors
- 
        .new(config = nil)
        
          A rule that disallows useless conditions in when clause where it is guaranteed to always return the same result. 
Instance Method Summary
Instance methods inherited from struct Ameba::Rule::Base
  
  
    
      ==(other)
    ==, 
    
  
    
      catch(source : Source)
    catch, 
    
  
    
      excluded?(source)
    excluded?, 
    
  
    
      group
    group, 
    
  
    
      hash
    hash, 
    
  
    
      initialize
    initialize, 
    
  
    
      name
    name, 
    
  
    
      special?
    special?, 
    
  
    
      test(source : Source, node : Crystal::ASTNode, *opts)test(source : Source) test
Constructor methods inherited from struct Ameba::Rule::Base
  
  
    
      new
    new
    
  
    
  Class methods inherited from struct Ameba::Rule::Base
  
  
    
      parsed_doc
    parsed_doc
    
  
  
    
    
    
  
    
    
    
  
    
    
    
  
    
    
    
  
Constructor Detail
        
        def self.new(config = nil)
        #
      
      
        A rule that disallows useless conditions in when clause where it is guaranteed to always return the same result.
For example, this is considered invalid:
case
when utc?
  io << " UTC"
when local?
  Format.new(" %:z").format(self, io) if local?
endAnd has to be written as the following:
case
when utc?
  io << " UTC"
when local?
  Format.new(" %:z").format(self, io)
endYAML configuration example:
Lint/UselessConditionInWhen:
  Enabled: true