Live data from Hacker News

GitHub Super Linter: one linter to rule them all

github.blog

241–250 of 360 posts

Re: GitHub Super Linter: one linter to rule them all

#241
post #134

Earlier quoted context omitted.

Code autoformatting is amazing and I never want to go back; even though I strenuously disagree with the particular formatting my team/company has chosen for python, I'm so relieved to never ever have a style discussion in PRs that I don't care about double quotes vs single quotes anymore. BUT I'm tired of seeing diff chunks on github where 95% of the chunk is because black/gofmt decided to change the formatting / ind…

Why don’t we just check ASTs in to git instead of text files ?

I have thought about this a bit in the past, and I think the answer is that the AST for a given blob of text can be different depending on which version of the language you interpret it with. consider 'print "foo"' in python 2.7:

    Python 2.7.15 (default, Feb 14 2019, 16:26:56)
    [GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.10.44.4)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import ast
    >>> ast.dump(ast.parse('print "foo"'))
    "Module(body=[Print(dest=None, values=[Str(s='foo')], nl=True)])"
but in python 3.7:

    Python 3.7.2 (default, Feb 14 2019, 16:12:42)
    [Clang 10.0.0 (clang-1000.10.44.4)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import ast
    >>> ast.parse('print "foo"')
    Traceback (most recent call last):
      File "", line 1, in 
      File "/Users/philsnow/.pyenv/versions/3.7.2/lib/python3.7/ast.py", line 35, in parse
        return compile(source, filename, mode, PyCF_ONLY_AST)
      File "", line 1
        print "foo"
                  ^
    SyntaxError: Missing parentheses in call to 'print'. Did you mean print("foo")?
nothing changed in the text, but the AST is different. What should get committed to this hypothetical "git-ast"?

The answer probably lies in creating a different abstraction , different building blocks. In git we have bytes -> blobs -> trees -> commits, where the bytes of a given file get annotated with a file name (and mode bits etc etc, gross posix things) by the tree object.

In git-ast, maybe the abstraction is bytes -> lexemes (which annotates the bytes with a language version, and thus lexer version) -> tree? I haven't gone down the thought experiment that far.

Re: GitHub Super Linter: one linter to rule them all

#242

No C/C++ support?

You don't have linters for C/C++ as far as I know. I guess they could have included code-formatters too, like clang-format.

lint for C has existed in one form or another for 42 years.

https://en.wikipedia.org/wiki/Lint_(software)

Re: GitHub Super Linter: one linter to rule them all

#244

Earlier quoted context omitted.

One of the hills I am willing to die on is auto-formatting. Code formatting is easily automated to an acceptable level, and people's personal preferences are subjective. I like to solve interesting problems, and concentrate on crafting high quality software. Manual code formatting contributes to neither of these disciplines. Code formatting is BORING robot work, not human work. Total pointless drudgery. Toiling away…

Not to mention it dirties up version control. It's a lot easier to tell which _significant_ things changed from the last commit when you're scanning a diff and no formatting changes are highlighted.

Ive seen heaps of autoformatters dirty up version control. Mostly when theyre fussing about new lines. I kind of wish autoformatters would just ignore new lines and focus on indentation alone. It would certainly cut down on the over zealous rules.

I also think formatting should be separate from linting but because they both require a parser people seem to think theyre the same thing.

Re: GitHub Super Linter: one linter to rule them all

#245
post #226

Earlier quoted context omitted.

Rather than “writing... with a model of how black will yield the final code in mind,” it’s more like “Oh, shit, Black made a real mess of this. Can I fix this without butchering the code?”

Yeah--we're basically second-order black formatters now. Not writing code that looks nice, but writing code so a tool that writes code will make it look nice.

Not really. At least that wasn't my intention to say that. Most of the time, I find Black does a Good Enough Job(tm) that I don't care to mess with it.

Re: GitHub Super Linter: one linter to rule them all

#246
Visual Basic (6 at least) had none of these issues. It formatted your code as soon as you pressed . Im don't recall ever having control over the formatter, which was great because everyone's code ended up looking the same and there was nothing they could do about it.

Re: GitHub Super Linter: one linter to rule them all

#247
post #149

Earlier quoted context omitted.

To me, because readability is the most important aspect of programming, and it needs to be done right.

But what do you get in that regard by not using black? Maybe in 1% of cases you’ll find a better way of formatting that everyone will also agree is better. That doesn’t seem worth very much at all to me, especially when by not using it you have to do a lot of manual work across the entire team now to get the 99% that is free with black.

google-java-format has been imposed from outside our team. It's not configurable, makes poor choices a lot more than 1% of the time, forces diffs to cover many more lines than needed, and vandalizes blocks that were already well-formatted by a professional for human readers.

I think there are few subjective style choices that are so egregious that a robot would have done a better job. Where I want enforcement is likely correctness and safety mistakes.

Re: GitHub Super Linter: one linter to rule them all

#248

Earlier quoted context omitted.

One of the hills I am willing to die on is auto-formatting. Code formatting is easily automated to an acceptable level, and people's personal preferences are subjective. I like to solve interesting problems, and concentrate on crafting high quality software. Manual code formatting contributes to neither of these disciplines. Code formatting is BORING robot work, not human work. Total pointless drudgery. Toiling away…

Not to mention it dirties up version control. It's a lot easier to tell which _significant_ things changed from the last commit when you're scanning a diff and no formatting changes are highlighted.

That doesn't necessarily mean that you need to check in auto-formatted changes. You can just autoformat the two revisions before feeding it to the diff program.

Of course, a lot of tooling simply isn't there for that, unfortunately, but that's what I see as the ideal solution.

Re: GitHub Super Linter: one linter to rule them all

#249
post #235
post #208

Earlier quoted context omitted.

Consistent style is more important than each block of code being perfectly pretty. You can still argue aesthetics, but they need to be applied across the entire codebase. Never having to bother someone because their PR doesn't meet the formatting guidelines is well worth it.

People at work nit: my code all the time. I just straight up ignore them. If they ask me why, I tell them to add an autoformat to our ci or shut the hell up. Fwiw, i use an auto formatter but its got problems with certain rules so i switch them off. The reason we dont have it turned on in ci is because these rules break code.

Yeah, auto formatter (or at least format validation) is a must.

Re: GitHub Super Linter: one linter to rule them all

#250
post #123
post #107

Earlier quoted context omitted.

Regarding "cross-platform": Docker for Windows used to be really terrible IMO (relied on VirtualBox, did not translate WSL paths, etc). I never managed to get the networking between VirtualBox, WSL and applications (e.g. Chrome running in Windows) working properly. Thankfully Microsoft rewrote WSL 2 in a way that makes it work much better with Docker.

I've also had some bad experiences with Docker for windows but that was quite a few (2+ years ago) - since then it's mostly been smooth sailing for me, even without WSL

My experience was that it used to be bad specifically because of the bad interactions with WSL (1)
Post reply on HN