eclipse-embed-cdt / eclipse-plugins

The Eclipse Embedded CDT plug-ins for Arm & RISC-V C/C++ developers (formerly known as the GNU MCU Eclipse plug-ins). Includes the archive of previous plug-ins versions, as Releases.
http://eclipse-embed-cdt.github.io/
Eclipse Public License 2.0
555 stars 130 forks source link

Code formatting and cleanup #469

Closed jonahgraham closed 3 years ago

jonahgraham commented 3 years ago

Here is the result of cleaning up all the embedcdt code. There are very few actual changes because the code had been fairly consistent.

Commit message 28c65169a3 has a lot of useful information on what has changed and why:

Bug #457: Scripts to apply code settings

This is the basis for running all the code cleanups. The sources
here are adapted from CDT's ones of the same names in
releng/scripts/do_all_code_cleanups.sh

The warning/error and formatting settings need to be stored in the project,
the org.eclipse.embedcdt.core's project is the "source" project for these
settings and the initial values for all these settings is from CDT. The
CDT ones are largely bases on default Eclipse ones.

The only change from CDT's settings is that non-externalized
strings are not a warning as embedcdt seems to have too many
non-externalized strings to make this warning useful.

The other significant project setting is that code cleanups are
applied automatically on save, this helps enforce contributors
match embedcdt's code style.

Subsequent commits provide the results of automatically running
all these cleanups.

The contents of commits after 28c65169a3 are the result of running the various cleanups based on the settings in this commit.

So, for example, if some formatting setting is undesirable, change it in commit 28c65169a3, discard subsequent ones and re-run the cleanup like this:

ECLIPSE=<PATH to eclipse with JDT installed>/eclipse scripts/style/do_all_code_cleanups.sh then the manual steps at the end of do_all_code_cleanups.sh.

These cleanups (and other checks too) are run for each Pull Request (gerrit actually!) for CDT to make sure that inconsistent code is not introduced into CDT. We can do that for embedcdt too at some point.

The warning settings are slightly different that what Eclipse does by default, leading to about 25 new warnings, mostly related to redundant code and questionably null uses, like Null comparison always yields false

Before this is merged I will add some documentation to README-MAINTAINER.md - I have run out of time today.

jonahgraham commented 3 years ago

I will rebuild this PR once #471 is merged so that @flit does not have any more conflicts to resolve when rebasing.

flit commented 3 years ago

@jonahgraham Thanks!