Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert tabs in multiline strings to 4 spaces #1960

Merged
merged 5 commits into from
Sep 29, 2019
Merged

Convert tabs in multiline strings to 4 spaces #1960

merged 5 commits into from
Sep 29, 2019

Conversation

schalkms
Copy link
Member

In the past this repo used tabs instead of 4 spaces for .kt files.
Ktlint doesn't convert tabs in multiline strings to spaces.
Please take a look at the following issue.
pinterest/ktlint#575

Therefore, the following command has been used for conversion.

find ./ -iname '*.kt' -type f -exec bash -c 'expand -t 4 "$0" | sponge "$0"' {} ;

  • ./ is recursively searching the given directory
  • -iname is a case insensitive match .kt files
  • type -f finds only regular files (no directories, binaries or symlinks)
  • -exec bash -c executes the following commands in a subshell for each file
  • expand -t 4 expands all tabs to 4 spaces
  • sponge soaks up standard input (from expand) and writes it to the same file

Source:
https://stackoverflow.com/a/43523362

In the past this repo used tabs instead of 4 spaces for .kt files.
Ktlint doesn't convert tabs in multiline strings to spaces.
Please take a look at the following issue.
pinterest/ktlint#575

Therefore, the following command has been used for conversion.

find ./ -iname '*.kt' -type f -exec bash -c 'expand -t 4 "$0" | sponge "$0"' {} \;

* ./ is recursively searching the given directory
* -iname is a case insensitive match .kt files
* type -f finds only regular files (no directories, binaries or symlinks)
* -exec bash -c executes the following commands in a subshell for each file
* expand -t 4 expands all tabs to 4 spaces
* sponge soaks up standard input (from expand) and writes it to the same file

Source:
https://stackoverflow.com/a/43523362
Copy link
Member Author

@schalkms schalkms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rules and formatting package will be changed in separate PRs, since this also requires manual intervention.

@3flex
Copy link
Member

3flex commented Sep 29, 2019

Thanks for doing this!

@3flex 3flex merged commit 0be10e8 into detekt:master Sep 29, 2019
sowmyav24 pushed a commit to sowmyav24/detekt that referenced this pull request Oct 1, 2019
@schalkms schalkms deleted the tabs-in-multiline-string branch October 3, 2019 20:40
smyachenkov pushed a commit to smyachenkov/detekt that referenced this pull request Dec 9, 2019
smyachenkov pushed a commit to smyachenkov/detekt that referenced this pull request Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants