Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Add support for tabs in indentation. #7867
As a stubborn tab user, I would like to have the ability to check, if all my code is indented with tabs, and also automatically correct indentation from spaces to tabs. So I:
Add support for indentation with tabs. Supports auto-correction.
Layout/IndentationStyle now can be configured:
# SupportedStyles: spaces, tabs Layout/IndentationStyle: EnforcedStyle: spaces # default
Previous functionality of Layout/Tab that looked for tabs in places other than indentation is removed.
I have fixed the linting issues and changed SupportedStyles to plural (spaces, tabs).
Concerning the renaming, of the cop, that would be a major version update then. Probably it is possible to get away with minor version update, if we split it into 2 different cops. Existing Layout/Tab will search and fix the tabs outside of indentation, and a new cop (e.g. Layout/IndentationStyle will look for and fix tabs/spaces only in indentation.
If you need, I can implement any strategy you suggest.
We still haven't released 1.0, so that's not a big deal. I doubt the rename would impact many people, anyways, as it's not common to disable this cop.
I do like this approach, though, as it's a bit weird that now the cop cares about both indentation and trailing tabs. I don't recall if it detects tabs in other contexts. I'm thinking that in essence the second cop can be something like "TrailingWhitespace" or something.
Let's go with the new name
I don't see much point in a cop checking for tabs at random place in the file. Hopefully the TrailingWhitespace cop already addresses trailing tabs.
This commit adds SupportedStyles to Layout/Tab - spaces and tabs. It also renames the cop to to Layout/IndentationStyle, as the old name no longer reflects its purpose. One notable difference is that before the `Layout/Tab` cop was warning on tabs anywhere in the source, but now we're focusing only on tabs used for indentation purposes.