Skip to content

Commit

Permalink
editorconfig: Remove [*] section and trim_trailing_whitespace.
Browse files Browse the repository at this point in the history
Wildcard sections [*] and [**] are unsafe because properties cannot be
applied safely to any filetype in general. For example, IDEs like
Visual Studio Code and KDevelop store configuration files in subfolders
like .vscode or .kdev4. Properties from wildcard sections also apply to
those files which is not safe in general.
Another example are patches created with 'git format-patch' which can
contain trailing whitespaces. When editing a patch, e.g. to fix a typo
in the title, trailing whitespaces should not be removed.

Property trim_trailing_whitespace should not be defined at all because
it is interpreted differently by editors. Some wipe whitespaces from
the whole file, others remove them from edited lines only and a few
change their behavior between releases [0]. Limiting the property to a
subset of files like *.c/*.h will not mitigate the issue:

Multiple definitions of a whitespace exist. Unicode considers a form
feed (0x0C) to be a whitespace [1]. QChar::isSpace() [2] from Qt
follows this definition, causing the Kate editor identify a form feed
as a trailing whitespace and removing it from sources [3]. This breaks
patches when editors remove form feeds and thus causing broken patches
which cannot be applied cleanly.

Removing trim_trailing_whitespace will be a minor inconvienence, in
particular because utilities/checkpatch.py and thus 0-day Robot will
prevent trailing whitespaces for our definition of a whitespace.

[0] KDE/ktexteditor@94b328f
[1] https://en.wikipedia.org/wiki/Whitespace_character
[2] https://github.com/qt/qtbase/blob/5628600a07295db6ed6683e97fafb0c45ddea505/src/corelib/text/qchar.h#L554
[3] https://github.com/KDE/ktexteditor/blob/10210ec1dd06afa1e7b19a4fff722a8a23719161/src/document/katedocument.cpp#L5643

Fixes: 07f6d6a ("Add editorconfig file.")

Signed-off-by: Jakob Meng <code@jakobmeng.de>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Reviewed-by: Robin-Jarry <rjarry@redhat.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
  • Loading branch information
JM1 authored and apconole committed Dec 4, 2023
1 parent 8b5fe2d commit 20022fb
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
# No wildcard sections [*] and [**] because properties cannot be
# applied safely to any filetype in general.

# Property trim_trailing_whitespace should not be defined at all
# because it is interpreted differently by editors.

[*.{c,h}]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
insert_final_newline = true
max_line_length = 79

[include/linux/**.h]
Expand Down

0 comments on commit 20022fb

Please sign in to comment.