lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANiq72njUr2wv7CA7W9ziRUf8mrVQPFEQfS7=it3zTVhJFvf3A@mail.gmail.com>
Date:   Fri, 26 May 2023 23:16:26 +0200
From:   Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To:     Íñigo Huguet <ihuguet@...hat.com>
Cc:     ojeda@...nel.org, masahiroy@...nel.org, jgg@...dia.com,
        mic@...ikod.net, danny@...ag0n.dev, linux-kernel@...r.kernel.org,
        corbet@....net, joe@...ches.com, linux@...musvillemoes.dk,
        willy@...radead.org, Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH v3] Add .editorconfig file for basic formatting

On Mon, May 8, 2023 at 10:59 AM Íñigo Huguet <ihuguet@...hat.com> wrote:
>
> Originally I sampled manually, but I have crafted a script to collect
> more data. It's not 100% reliable, but good to get an idea. It reads
> the leading whitespaces and if >80% of the lines have one kind of
> indentation, it considers that it's the one used in that file. The
> results, filtered to show only the relevant ones, are pasted at the
> end.

This is useful -- thanks a lot for working on collecting it!

> These are some personal conclusions from the script's results:
> - .py: although the official and most widely used style in the
> community is 4-space indentation, in Linux tree many files use tabs.
> What should we do here? 4-space is the clear standard for python...

Yeah, this is the kind of thing that worries me and why I asked --
what do editors do when they have the config saying it is 4-spaces,
but the file is tabs? Do they adjust, do they convert the entire file,
or do they simply start mixing indentation styles? Does the
`.editorconfig` spec say anything about it? For instance, here is an
issue about this sort of problem:

    https://github.com/editorconfig/editorconfig-vscode/issues/329

If the rule could be applied only to new files, then it would be
fairly easy to decide, given the majority uses 4-spaces and it nicely
aligns with PEP 8, Black, etc. But unless we are quite sure we are not
annoying developers, I would avoid specifying anything in these cases.

In some cases (e.g. few files), you may be able to propose to
normalize the indentation style treewide for that extension.

> - .rb: only one file in the whole tree
> - .pm: only 3 files in the whole tree

I guess you could also ignore extensions without many matches in order
to simplify -- they can always be added later, ideally by their
maintainers.

> - Files with many different indentations, better not to specify them:
> rst, cocci, tc, xsl, manual pages
> - Files that we should specify, tab indented: awk, dts, dtsi, dtso, s, S
> - Files that we might specify, with preference for tab indenting but
> not 100% clear: sh, bash, pl
> - Files in tools/perf/scripts/*/bin/*: there is no clear formatting
> for any file type, only for .py files that are tab-indented. To get
> these results I've run my script from tools/perf/scripts directory.

If all Python tab-indented files are in a given folder, then would it
be possible to provide an `.editorconfig` for that folder, and then
4-spaces for the global one? i.e. splitting the problem across folders
may be a solution (within reason, of course, i.e. as long as we don't
fill the kernel with `.editorconfig` files... :)

> I'm only aware of Clang and Rust formatter configs in Linux tree, and
> I think this complies with them. Do you know about any other?

There is `scripts/checkpatch.pl`, which I guess may be counted as one
since one can fix what it complains about manually (and I think it has
some "fix in place" support too).

There is also `Documentation/devicetree/bindings/.yamllint`.

In addition, some may be using formatters in a default config? e.g.
Black for some of the Python scripts.

Cheers,
Miguel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ