diff mbox series

tools: add EditorConfig file

Message ID 20191018075954.29715-1-robin.jarry@6wind.com (mailing list archive)
State Superseded, archived
Headers show
Series tools: add EditorConfig file | expand

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compilation success Compile Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed

Commit Message

Robin Jarry Oct. 18, 2019, 7:59 a.m. UTC
EditorConfig is a file format and collection of text editor plugins for
maintaining consistent coding styles between different editors and IDEs.

Initialize the file following the coding rules in
doc/guides/contributing/coding_style.rst,
doc/guides/contributing/documentation.rst and
doc/guides/contributing/patches.rst.

In order for this file to be taken into account (unless they use an
editor with built-in EditorConfig support), developers will have to
install a plugin.

Note: The max_line_length property is only supported by a limited number
of EditorConfig plugins. It will be ignored if unsupported.

Add this new file in MAINTAINERS in the "Developers and Maintainers
Tools" section.

Link: https://editorconfig.org/
Link: https://github.com/editorconfig/editorconfig-emacs
Link: https://github.com/editorconfig/editorconfig-vim
Link: https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#max_line_length
Cc: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
---
 .editorconfig | 23 +++++++++++++++++++++++
 MAINTAINERS   |  1 +
 2 files changed, 24 insertions(+)
 create mode 100644 .editorconfig

Comments

Burakov, Anatoly Oct. 18, 2019, 9:08 a.m. UTC | #1
On 18-Oct-19 8:59 AM, Robin Jarry wrote:
> EditorConfig is a file format and collection of text editor plugins for
> maintaining consistent coding styles between different editors and IDEs.
> 
> Initialize the file following the coding rules in
> doc/guides/contributing/coding_style.rst,
> doc/guides/contributing/documentation.rst and
> doc/guides/contributing/patches.rst.
> 
> In order for this file to be taken into account (unless they use an
> editor with built-in EditorConfig support), developers will have to
> install a plugin.
> 
> Note: The max_line_length property is only supported by a limited number
> of EditorConfig plugins. It will be ignored if unsupported.
> 
> Add this new file in MAINTAINERS in the "Developers and Maintainers
> Tools" section.
> 
> Link: https://editorconfig.org/
> Link: https://github.com/editorconfig/editorconfig-emacs
> Link: https://github.com/editorconfig/editorconfig-vim
> Link: https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#max_line_length
> Cc: Thomas Monjalon <thomas@monjalon.net>
> Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
> ---

+1, we need things like this. It would also be good to finally get a 
.clang-format file...
Stephen Hemminger Oct. 18, 2019, 3:47 p.m. UTC | #2
On Fri, 18 Oct 2019 09:59:54 +0200
Robin Jarry <robin.jarry@6wind.com> wrote:

Looks good, you should add a reference to
https://editorconfig.org so others understand this

> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright 2019 6WIND S.A.
> +
> +root = true
> +
> +[*]
> +end_of_line = lf
> +insert_final_newline = true
> +charset = utf-8
> +indent_style = tab
> +tab_width = 8
> +max_line_length = 80
> +
> +[**.py]
> +indent_style = space
> +indent_size = 4

In the example on web site, they use
[*.py] not [**.py]
Stephen Hemminger Oct. 18, 2019, 3:48 p.m. UTC | #3
On Fri, 18 Oct 2019 09:59:54 +0200
Robin Jarry <robin.jarry@6wind.com> wrote:

> diff --git a/.editorconfig b/.editorconfig
> new file mode 100644
> index 000000000000..c5704d89b8c6
> --- /dev/null
> +++ b/.editorconfig
> @@ -0,0 +1,23 @@
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright 2019 6WIND S.A.
> +
> +root = true
> +
> +[*]
> +end_of_line = lf
> +insert_final_newline = true
> +charset = utf-8
> +indent_style = tab
> +tab_width = 8
> +max_line_length = 80

Why not add this (since git doesn't like trailing whitespace).

trim_trailing_whitespace=true
Robin Jarry Oct. 18, 2019, 3:55 p.m. UTC | #4
2019-10-18, Stephen Hemminger:
> In the example on web site, they use
> [*.py] not [**.py]

I've tested both forms, they work the same. I don't have a strong
opinion on this, I can change to [*.py].
Robin Jarry Oct. 18, 2019, 3:56 p.m. UTC | #5
2019-10-18, Stephen Hemminger:
> Why not add this (since git doesn't like trailing whitespace).
> 
> trim_trailing_whitespace=true

Because EditorConfig applies the setting to the whole file when saving.
This has chances of trimming white space on lines that you did not
modify. I figure this is not what we want.
Stephen Hemminger Oct. 18, 2019, 4:08 p.m. UTC | #6
On Fri, 18 Oct 2019 17:56:48 +0200
Robin Jarry <robin.jarry@6wind.com> wrote:

> 2019-10-18, Stephen Hemminger:
> > Why not add this (since git doesn't like trailing whitespace).
> > 
> > trim_trailing_whitespace=true  
> 
> Because EditorConfig applies the setting to the whole file when saving.
> This has chances of trimming white space on lines that you did not
> modify. I figure this is not what we want.
> 


Current DPDK does not have trailing white space, I run a script over it
perodically to check.
Bruce Richardson Oct. 21, 2019, 9:01 a.m. UTC | #7
On Fri, Oct 18, 2019 at 09:08:25AM -0700, Stephen Hemminger wrote:
> On Fri, 18 Oct 2019 17:56:48 +0200
> Robin Jarry <robin.jarry@6wind.com> wrote:
> 
> > 2019-10-18, Stephen Hemminger:
> > > Why not add this (since git doesn't like trailing whitespace).
> > > 
> > > trim_trailing_whitespace=true  
> > 
> > Because EditorConfig applies the setting to the whole file when saving.
> > This has chances of trimming white space on lines that you did not
> > modify. I figure this is not what we want.
> > 
> 
> 
> Current DPDK does not have trailing white space, I run a script over it
> perodically to check.

+1 for including this.
diff mbox series

Patch

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000000..c5704d89b8c6
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,23 @@ 
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2019 6WIND S.A.
+
+root = true
+
+[*]
+end_of_line = lf
+insert_final_newline = true
+charset = utf-8
+indent_style = tab
+tab_width = 8
+max_line_length = 80
+
+[**.py]
+indent_style = space
+indent_size = 4
+
+[**.rst]
+indent_style = space
+indent_size = 3
+
+[COMMIT_EDITMSG]
+max_line_length = 72
diff --git a/MAINTAINERS b/MAINTAINERS
index f8a56e2e2615..16b4eb18cafa 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -82,6 +82,7 @@  F: doc/
 
 Developers and Maintainers Tools
 M: Thomas Monjalon <thomas@monjalon.net>
+F: .editorconfig
 F: MAINTAINERS
 F: devtools/check-dup-includes.sh
 F: devtools/check-maintainers.sh