You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2019/02/03 17:34:53 UTC
[incubator-plc4x] branch develop updated: - Fixing more sonarqube
findings
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new de02436 - Fixing more sonarqube findings
de02436 is described below
commit de02436bc7c97c43365ebc216d3d1c6dddeeadb2
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Sun Feb 3 18:04:35 2019 +0100
- Fixing more sonarqube findings
---
.../client/src/main/royale/service/RobotService.as | 2 +-
.../plc4x/examples/robot/controllers/RobotController.java | 13 ++++++++-----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/examples/hello-webapp/client/src/main/royale/service/RobotService.as b/examples/hello-webapp/client/src/main/royale/service/RobotService.as
index 03aaaaa..2dd3772 100644
--- a/examples/hello-webapp/client/src/main/royale/service/RobotService.as
+++ b/examples/hello-webapp/client/src/main/royale/service/RobotService.as
@@ -33,7 +33,7 @@ public class RobotService extends EventDispatcher {
/**
* constructor
*/
- public function RobotService():void {
+ public function RobotService() {
remoteService = new HTTPService();
remoteService.addEventListener(HTTPConstants.COMPLETE, completeHandler);
_url = "api/robot/move";
diff --git a/examples/hello-webapp/service/src/main/java/org/apache/plc4x/examples/robot/controllers/RobotController.java b/examples/hello-webapp/service/src/main/java/org/apache/plc4x/examples/robot/controllers/RobotController.java
index 0ff47c3..0b6c9bc 100644
--- a/examples/hello-webapp/service/src/main/java/org/apache/plc4x/examples/robot/controllers/RobotController.java
+++ b/examples/hello-webapp/service/src/main/java/org/apache/plc4x/examples/robot/controllers/RobotController.java
@@ -41,10 +41,10 @@ public class RobotController {
private static final Logger logger = LoggerFactory.getLogger(RobotController.class);
- private static byte MOTOR_RIGHT_BACKWARDS = 0x01;
- private static byte MOTOR_RIGHT_ON = 0x02;
- private static byte MOTOR_LEFT_BACKWARDS = 0x04;
- private static byte MOTOR_LEFT_ON = 0x08;
+ private static final byte MOTOR_RIGHT_BACKWARDS = 0x01;
+ private static final byte MOTOR_RIGHT_ON = 0x02;
+ private static final byte MOTOR_LEFT_BACKWARDS = 0x04;
+ private static final byte MOTOR_LEFT_ON = 0x08;
@Value("${plc4x.connection-string}")
private String connectionString;
@@ -62,7 +62,7 @@ public class RobotController {
@RequestMapping("move")
public boolean move(@RequestParam(value="direction", defaultValue="stop") String direction) {
logger.info("Move in direction: " + direction);
- byte state = 0;
+ byte state;
switch (direction) {
case "forward-right":
state = MOTOR_LEFT_ON;
@@ -88,6 +88,9 @@ public class RobotController {
case "backward-left":
state = (byte) (MOTOR_RIGHT_BACKWARDS | MOTOR_RIGHT_ON);
break;
+ default:
+ state = 0;
+ break;
}
try {
PlcWriteRequest updateRequest = connection.writeRequestBuilder().addItem("state", addressString, state).build();