Skip to content

Commit 2c36e41

Browse files
authoredJun 7, 2023
Refactor: apply best practices and coding guidelines globally (OpenEMS#2209)
The PR contains strictly **NO LOGIC CHANGES**, but applies best practices and coding guidelines (https://openems.github.io/openems.io/openems/latest/contribute/coding-guidelines.html) globally in OpenEMS Edge/Backend, e.g. - Use separate Interface and Implementation files for OpenEMS Edge Components - Move ChannelIds to Interfaces ("Natures" - https://openems.github.io/openems.io/openems/latest/coreconcepts.html#_nature) - Rename Component files equal to Factory-ID (makes Ctrl+R in Eclipse IDE much more convenient to use) - Reduce variable scope; use `private` wherever possible (e.g. for the `activate()`-method). This is enforced by adding and applying Checkstyle `VisibilityModifierCheck` (see https://checkstyle.sourceforge.io/apidocs/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheck.html) - Sort variables in code (from `public static final` to `private`; @reference to constructor to @activate, @Modifed, @deactivate) - Use short JavaDoc for single-line comments - Use `@EventTopics` - Always implement @deactivate - Remove `package-info.java` if not necessary (i.e. reduce package scope) - Add (at least simple) JUnit tests - Update BND Bundle templates
1 parent 86f7ae8 commit 2c36e41

File tree

1,187 files changed

+72612
-65693
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,187 files changed

+72612
-65693
lines changed
 

‎cnf/checkstyle.xml

+7
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@
188188
<message key="name.invalidPattern" value="Method name ''{0}'' must match pattern ''{1}''."/>
189189
</module>
190190
<module name="SingleLineJavadoc">
191+
<property name="severity" value="ignore"/>
191192
<property name="ignoreInlineTags" value="false"/>
193+
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
192194
</module>
193195
<module name="EmptyCatchBlock">
194196
<property name="exceptionVariableName" value="expected"/>
@@ -206,6 +208,11 @@
206208
<property name="ignoreMethodNamesRegex" value="doc|set.+|build"/>
207209
<property name="tokens" value="METHOD_DEF"/>
208210
</module>
211+
<module name="VisibilityModifier">
212+
<property name="protectedAllowed" value="true"/>
213+
<property name="allowPublicFinalFields" value="true"/>
214+
<property name="allowPublicImmutableFields" value="true"/>
215+
</module>
209216
</module>
210217
<module name="LineLength">
211218
<property name="severity" value="ignore"/>

‎io.openems.backend.alerting/src/io/openems/backend/alerting/Alerting.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ public class Alerting extends AbstractOpenemsBackendComponent implements EventHa
4141
private static final byte THREAD_POOL_SIZE = 2;
4242
private static final byte THREAD_QUEUE_WARNING_THRESHOLD = 50;
4343

44-
private final Logger log = LoggerFactory.getLogger(Alerting.class);
44+
protected final Scheduler scheduler;
4545

46+
private final Logger log = LoggerFactory.getLogger(Alerting.class);
4647
private final ThreadPoolExecutor executor;
4748

4849
@Reference
@@ -51,7 +52,6 @@ public class Alerting extends AbstractOpenemsBackendComponent implements EventHa
5152
@Reference
5253
protected Mailer mailer;
5354

54-
protected final Scheduler scheduler;
5555
protected Handler<?>[] handlers = {};
5656

5757
protected Alerting(Scheduler scheduler) {

0 commit comments

Comments
 (0)
Please sign in to comment.