Giter Site home page Giter Site logo

Comments (7)

dlenski avatar dlenski commented on June 15, 2024 1

PS: I've made a fix/patch for this "issue" - are you interested in pull requests ? :-)

Yep!

from wtf.

dlenski avatar dlenski commented on June 15, 2024

check for specific non-mixed tab or space indentation

Not sure that I understand. Can you give an example of text files which are/aren't matching this kind of condition?

from wtf.

uffejakobsen avatar uffejakobsen commented on June 15, 2024

check for specific non-mixed tab or space indentation

Not sure that I understand. Can you give an example of text files which are/aren't matching this kind of condition?

I'm using wtf to do checks on a C/C++ -source tree.
The formatting rules for the source tree specify that all indentation in the C/C++ files should be done with spaces - no tabs are allowed for indentation.
I may have missed something - but I have failed to find a way to use wtf to check that only spaces are used in indentation.

from wtf.

dlenski avatar dlenski commented on June 15, 2024

I may have missed something - but I have failed to find a way to use wtf to check that only spaces are used in indentation.

Do these options not cover what you're trying to do?

Tabs and Spaces:
  -s, --tab-space-mix   Make sure no mixed spaces and/or tabs exist in leading
                        whitespace; fix requires -x or -y SPACES (default
                        report)
  -S, --report-tab-space-mix
  -Is, --ignore-tab-space-mix
  -x NS, --change-tabs NS
                        Change each tab characters in leading whitespace to NS
                        spaces.
  -y NS, --change-spaces NS
                        Change NS consecutive spaces in leading whitespace to
                        tab character.

Warn-only:

$ printf "\t    blah\n" | wtf -0 -S
<stdin> LINE 1: WARNING: mixed use of spaces and tabs at beginning of line
<stdin>:
	CHOPPED 0 lines with trailing space
	CHOPPED 0 blank lines at EOF
	no change to newline at EOF
	CHANGED 0 line endings which didn't match lf from first line
	WARNED ABOUT 1 lines with mixed tabs/spaces

Replace tabs with 4 spaces:

$ printf "\t    blah\n" | wtf -sx4 -0
<stdin> LINE 1: WARNING: mixed use of spaces and tabs at beginning of line
<stdin>:
	CHOPPED 0 lines with trailing space
	CHOPPED 0 blank lines at EOF
	no change to newline at EOF
	CHANGED 0 line endings which didn't match lf from first line
	WARNED ABOUT 1 lines with mixed tabs/spaces
	CHANGED tabs to 4 spaces on 1 lines

from wtf.

uffejakobsen avatar uffejakobsen commented on June 15, 2024

Ah - I failed to understand that the -x option could be used for the scenario that I described above.

From the help/description I got the impression that it was only meant for changing files - and as I only wanted to check/detect if a condition was present without changing the files - I wrote off that option from the beginning.

Thanks for your swift response and help 👍 - I'm closing this issue right away :-)

from wtf.

uffejakobsen avatar uffejakobsen commented on June 15, 2024

Sorry for reopening this issue
I've now been playing around with the -x and -y options...

As mentioned earlier - I'm now able to get WTF to do what I needed.

But I think that there is some inconsistency in the reporting of what WTF have done or seen

Background:
I'm using WTF in a continuous pipeline - WTF will not change anything - only validate for acceptance or rejection - hence -0 (dry-run option is used)
In case of rejection - reporting the reasons for the details is important (not too verbose - but enough to point the user to the exact problem)

As mentioned earlier - I'm validating a C/C++ source tree where only space is allowed in the indentation - not tabs

In the case of mixed indentation WTF (with option -S) already reports a warning of every line (number) that is found - that is perfect for my use case :-)

Running WTF with options "-0 -S -x 1" enables me to also detect lines that have only (non-mixed) tab indentation.
But they are not reported in the same detail level (with line number) as mixed indentation lines - only mention is in the summary where they are reported as a total changed count.

Now I know that raising the verbose level to >= 2 (-vv) will somewhat fix this.
But that gets too verbose for my use case (the users) as the whole line contents is quoted in the output

I do realize that this is a special corner case - but I find WTF super flexible in every other way - except for this little "issue" that I've found
I'm not sure if I've managed to explain the problem to a level that makes it understandable to others than myself (english is not my native language)

PS: I've made a fix/patch for this "issue" - are you interested in pull requests ? :-)

from wtf.

uffejakobsen avatar uffejakobsen commented on June 15, 2024

PR #21 created :-)

from wtf.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.