Address warning: mismatched indentations at 'when' with 'case'
and warning: mismatched indentations at 'else' with 'case'
Recently Rails railties CI with ruby-head, which is now ruby2.6.0.dev has been failing due to this error.
The log length has exceeded the limit of 4 MB (this usually means that the test suite is raising the same exception over and over).
Here are the number of warnings of crass-1.0.3.
$ grep warning log.txt | sort | uniq -c | sort -n |grep crass
68 /home/travis/.rvm/gems/ruby-head/gems/crass-1.0.3/lib/crass/parser.rb:405: warning: mismatched indentations at 'when' with 'case' at 402
68 /home/travis/.rvm/gems/ruby-head/gems/crass-1.0.3/lib/crass/parser.rb:408: warning: mismatched indentations at 'when' with 'case' at 402
68 /home/travis/.rvm/gems/ruby-head/gems/crass-1.0.3/lib/crass/parser.rb:415: warning: mismatched indentations at 'when' with 'case' at 402
68 /home/travis/.rvm/gems/ruby-head/gems/crass-1.0.3/lib/crass/parser.rb:420: warning: mismatched indentations at 'else' with 'case' at 402
68 /home/travis/.rvm/gems/ruby-head/gems/crass-1.0.3/lib/crass/tokenizer.rb:540: warning: mismatched indentations at 'when' with 'case' at 539
68 /home/travis/.rvm/gems/ruby-head/gems/crass-1.0.3/lib/crass/tokenizer.rb:543: warning: mismatched indentations at 'when' with 'case' at 539
68 /home/travis/.rvm/gems/ruby-head/gems/crass-1.0.3/lib/crass/tokenizer.rb:553: warning: mismatched indentations at 'when' with 'case' at 539
68 /home/travis/.rvm/gems/ruby-head/gems/crass-1.0.3/lib/crass/tokenizer.rb:559: warning: mismatched indentations at 'when' with 'case' at 539
68 /home/travis/.rvm/gems/ruby-head/gems/crass-1.0.3/lib/crass/tokenizer.rb:570: warning: mismatched indentations at 'else' with 'case' at 539
$
These warnings can be reproduced by running rake command.
$ rake
NOTE: Testing support for frozen string literals
/home/yahonda/git/crass/lib/crass/parser.rb:405: warning: mismatched indentations at 'when' with 'case' at 402
/home/yahonda/git/crass/lib/crass/parser.rb:408: warning: mismatched indentations at 'when' with 'case' at 402
/home/yahonda/git/crass/lib/crass/parser.rb:415: warning: mismatched indentations at 'when' with 'case' at 402
/home/yahonda/git/crass/lib/crass/parser.rb:420: warning: mismatched indentations at 'else' with 'case' at 402
/home/yahonda/git/crass/lib/crass/tokenizer.rb:540: warning: mismatched indentations at 'when' with 'case' at 539
/home/yahonda/git/crass/lib/crass/tokenizer.rb:543: warning: mismatched indentations at 'when' with 'case' at 539
/home/yahonda/git/crass/lib/crass/tokenizer.rb:553: warning: mismatched indentations at 'when' with 'case' at 539
/home/yahonda/git/crass/lib/crass/tokenizer.rb:559: warning: mismatched indentations at 'when' with 'case' at 539
/home/yahonda/git/crass/lib/crass/tokenizer.rb:570: warning: mismatched indentations at 'else' with 'case' at 539
Run options: --seed 1077
... snip ...
$
How to address these warnings
These warnings can be addressed by using RuboCop. I do not request to install RuboCop permanently in this repository then just created it temporary and remove them.
Create .rubocop_todo.yml file
$ rubocop --auto-gen-config
Edit .rubocop_todo.yml generated and modify as follows.
Replace Exclude with Include under Layout/CaseIndentication:
and remove test/support/common.rb' since only lib/crass/parser.rb and lib/crass/tokenizer.rb files are reported by rake.
Address
warning: mismatched indentations at 'when' with 'case'
andwarning: mismatched indentations at 'else' with 'case'
Recently Rails railties CI with ruby-head, which is now ruby2.6.0.dev has been failing due to this error.
Here are the number of warnings of crass-1.0.3.
These warnings can be reproduced by running rake command.
How to address these warnings
These warnings can be addressed by using RuboCop. I do not request to install RuboCop permanently in this repository then just created it temporary and remove them.
Create .rubocop_todo.yml file
Edit
.rubocop_todo.yml
generated and modify as follows.Replace
Exclude
withInclude
underLayout/CaseIndentication:
and remove test/support/common.rb' since only lib/crass/parser.rb and lib/crass/tokenizer.rb files are reported by rake.Execute rubocop -a (--auto-correct) option
Remove .rubocop.yml and .rubocop_todo.yml