Skip to contentSkip to conversation

tools: add EditorConfig file

PATCH Superseded Robin Jarry 5 participants 10 messages Oct 18, 2019 – Feb 22, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: add EditorConfig file

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.

---
 .editorconfig | 23 +++++++++++++++++++++++
 MAINTAINERS   |  1 +
 2 files changed, 24 insertions(+)
 create mode 100644 .editorconfig
.editorconfig new file +23 -0
new file mode 100644
index 000000000000..c5704d89b8c6
@@ -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
MAINTAINERS +1 -0
index f8a56e2e2615..16b4eb18cafa 100644
@@ -82,6 +82,7 @@ F: doc/
 
 Developers and Maintainers Tools
 M: Thomas Monjalon <[email protected]>
+F: .editorconfig
 F: MAINTAINERS
 F: devtools/check-dup-includes.sh
 F: devtools/check-maintainers.sh
Signature · 1 line
2.23.0
#1 lore raw
Quoted 18 lines · Robin Jarry

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.

Quoted 7 lines

---

+1, we need things like this. It would also be good to finally get a .clang-format file...

Signature · 2 lines
Thanks,
Anatoly
#2 lore raw
In reply to Robin Jarry

On Fri, 18 Oct 2019 09:59:54 +0200
Robin Jarry <[email protected]> wrote:

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

Quoted 6 lines
.editorconfig new file +6 -0
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2019 6WIND S.A.
+
+root = true
+
+[*]

.editorconfig line 16

Quoted 10 lines
.editorconfig new file +10 -0
+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]

#3 lore raw

2019-10-18, Stephen Hemminger:

Quoted 2 lines

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].

Signature · 1 line
Robin
#4 lore raw
In reply to Robin Jarry
Quoted 8 lines · On Fri, 18 Oct 2019 09:59:54 +0200 Robin Jarry <[email protected]> wrote:
.editorconfig new file +2 -0
new file mode 100644
index 000000000000..c5704d89b8c6
@@ -0,0 +1,23 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2019 6WIND S.A.

.editorconfig line 12

Quoted 10 lines
.editorconfig new file +10 -0
+
+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

#5 lore raw

2019-10-18, Stephen Hemminger:

Quoted 3 lines

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.

Signature · 1 line
Robin
#6 lore raw
Quoted 9 lines · On Fri, 18 Oct 2019 17:56:48 +0200 Robin Jarry <[email protected]> wrote:

2019-10-18, Stephen Hemminger:

Quoted 3 lines

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.

#7 lore raw
Quoted 8 lines · Stephen Hemminger
Quoted 5 lines · On Fri, 18 Oct 2019 17:56:48 +0200 Robin Jarry <[email protected]> wrote:

2019-10-18, Stephen Hemminger:

Quoted 3 lines

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

trim_trailing_whitespace=true

Quoted 8 lines
Quoted 4 lines

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.

#8 lore raw

PATCH v2 1/1 devtools: add EditorConfig file

In reply to Robin Jarry

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.

---
Changelog:

v2:

- Add link to editorconfig.org in file for syntax reference.
- Use [*.EXT] syntax for section headers (as shown on home page).
- Add trim_trailing_whitespace option.

 .editorconfig | 25 +++++++++++++++++++++++++
 MAINTAINERS   |  1 +
 2 files changed, 26 insertions(+)
 create mode 100644 .editorconfig
.editorconfig new file +25 -0
new file mode 100644
index 000000000000..d70582557497
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2019 6WIND S.A.
+# See https://editorconfig.org/ for syntax reference.
+
+root = true
+
+[*]
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = 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
MAINTAINERS +1 -0
index f8a56e2e2615..16b4eb18cafa 100644
@@ -82,6 +82,7 @@ F: doc/
 
 Developers and Maintainers Tools
 M: Thomas Monjalon <[email protected]>
+F: .editorconfig
 F: MAINTAINERS
 F: devtools/check-dup-includes.sh
 F: devtools/check-maintainers.sh

--
2.23.0

#9 lore raw

Re: [dpdk-dev] [PATCH v2] devtools: add EditorConfig file

25/10/2019 16:04, Robin Jarry:

Quoted 29 lines

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.

Quoted 8 lines

---
Changelog:

v2:

- Add link to editorconfig.org in file for syntax reference.
- Use [*.EXT] syntax for section headers (as shown on home page).
- Add trim_trailing_whitespace option.

This patch was forgotten, sorry.

Applied, thanks it looks to be a good addition.