Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp46027rwd; Fri, 26 May 2023 14:43:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Wf3i8gJVeAtXuVirvk8KUnZKN0pS+d0QtRqMho4FBN+oKdRjj6ZNrGZ9oz37TsxVEQWcD X-Received: by 2002:a17:90a:d712:b0:256:2ee5:aebc with SMTP id y18-20020a17090ad71200b002562ee5aebcmr3007872pju.18.1685137435438; Fri, 26 May 2023 14:43:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685137435; cv=none; d=google.com; s=arc-20160816; b=lPIV/y8RVsMCxhxju1mW0sWZ4+8a3bVNVIlMSV5hDyR+fHk9uKZMfAwXVANSoABiKf DRwOEGCRmX1f3SQt3ll8HDY0Ob8c+AIpdRLpTinDVYWoIGV3nmTxFVE70hrNUjZRerPw Hj5GrxgYpS2xk3aM8wcNlLEVCEa2ZfNlIWZoBSGyLtLdXhz67ekufFxnVa4fHRPR5y1+ AGaDsOEC0Ym1RfyR4EZmrBuih+P04NqAX2M24jBDNAkqjfKvsJPlChTuhieKA4vCofW0 h6fQlyi4LK97fWRYI9Y7hFXfoGYXOhnQ69Ss6gZafVHEeAeeFfV9/pYujSHrr+IUAHFI e++A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=GMxB33ZwtJ62Rd3pdsfVx0QDMuGQJeUN8Db0SpoNE7c=; b=W2wt/+qasATunzMtYEADYUe3KpYrs8/2QNnwRHhLXwSa4p0ffT3Kl9rptbUqhe7K8V 2t5Slpozs+xJXXmNzw5qPw4yYc3NSCg0C9ylPOqRpTbNmhbUBGcnTtH5clTSDnMy/qSs B5113MRrTeMwZkKtmttuMu9k1U+GEdF1qdhiOp5qA8Za4R+J+X+TSyI7Gxti/aykRzoN 6ikIgv5v+M7m9qgFgEC2ZAwYrqT/I74o2Dp/G8iEEEyf4J2DeDzrK53TByyWMiPNqNPv xedsNsRkw0cC6NOTvbteGwmTHPHOiBKQj41K/9hUQ/QaJBg8hG9zEmwazvrlsoGLBC+A +3hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=WO8ETJpr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v15-20020a63bf0f000000b0053eef60f942si4176765pgf.764.2023.05.26.14.43.40; Fri, 26 May 2023 14:43:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=WO8ETJpr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237885AbjEZVQl (ORCPT + 99 others); Fri, 26 May 2023 17:16:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237412AbjEZVQk (ORCPT ); Fri, 26 May 2023 17:16:40 -0400 Received: from mail-yw1-x112e.google.com (mail-yw1-x112e.google.com [IPv6:2607:f8b0:4864:20::112e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17FFABC for ; Fri, 26 May 2023 14:16:39 -0700 (PDT) Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-565a6837a0bso18724237b3.3 for ; Fri, 26 May 2023 14:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685135798; x=1687727798; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=GMxB33ZwtJ62Rd3pdsfVx0QDMuGQJeUN8Db0SpoNE7c=; b=WO8ETJpr3D8s+L8V7BZGdNHhdBMauE8nCTE+BKsOSVTHrKqsPSboOCcRv4PWnkjmEw jK5L1C0daoeXuXDI7ZXrWWRm8Mrf2U0RNr2eT1JIM2bgFi/VV2R8C+nW5XPpKWVKHDdl enKGgowQZCPHxHaosuumQ0IPA8EJvaTrHFjahnsa0CCW9I7TpoTIM4IKw4KFBeBzsias G2qYE6Otw/RgQ11EASK9n7LTUiUFFtdpXj2NUNRYDBpkZNzKHDCXK+7kmxNeYeLj4FD0 /ViPAmBwjCpUrhWjNxBlomdfAP3b1tme0MH2qsrVPARPUzEW9+17V3gg92Z58EGEu/Tf j8hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685135798; x=1687727798; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GMxB33ZwtJ62Rd3pdsfVx0QDMuGQJeUN8Db0SpoNE7c=; b=Gxb1OwxGNMEwzXMzBTGdEcIJtyw3oGFBOhSM/RnwJZxOU3Mza4n0hiCo0tT4D4EXyd q/eV/kf2QbaKsMIZrRyHDyzy0oUaliOJvXYTTpifqKtEepJsttCfHFRTU3Ga4rB3l2z0 BNBTKu8OwH+E/VDRXYFS52TffxBrRLmGQ4SgaofLYQ7zqtDv8QJSDN4HgXvrEo2cQ4vq zwOkPvXACEBJh26pT2NGHIyReKsLutVnE5tILn2NVVAcSbQKVuWMb9AaPVC1Pfgn8bYh 1/lQl+E+yawW6Dpon60ejcAG98kXISsINIHHBhJanEaOpb/KsHBWkmyZIpypE59XtTok IiKg== X-Gm-Message-State: AC+VfDypCw3BYIIyYaZaYL0nf92GzNwUkeK55E2ReOfXz139RR6eN0y4 g+7u9RrGBHkloFGcynqGCBX+jci5Y8zBnky5qlw= X-Received: by 2002:a81:8747:0:b0:552:a0fc:6827 with SMTP id x68-20020a818747000000b00552a0fc6827mr3311805ywf.52.1685135798208; Fri, 26 May 2023 14:16:38 -0700 (PDT) MIME-Version: 1.0 References: <20230414101052.11012-1-ihuguet@redhat.com> In-Reply-To: From: Miguel Ojeda Date: Fri, 26 May 2023 23:16:26 +0200 Message-ID: Subject: Re: [PATCH v3] Add .editorconfig file for basic formatting To: =?UTF-8?B?w43DsWlnbyBIdWd1ZXQ=?= Cc: ojeda@kernel.org, masahiroy@kernel.org, jgg@nvidia.com, mic@digikod.net, danny@kdrag0n.dev, linux-kernel@vger.kernel.org, corbet@lwn.net, joe@perches.com, linux@rasmusvillemoes.dk, willy@infradead.org, Andrew Morton Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 8, 2023 at 10:59=E2=80=AFAM =C3=8D=C3=B1igo Huguet 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