diff --git a/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/ButtonWidget.vue b/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/ButtonWidget.vue index 599569107..a1fd24e25 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/ButtonWidget.vue +++ b/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/ButtonWidget.vue @@ -92,13 +92,24 @@ export default { async onClick() { const lines = this.eval.split(';;') // Create local references to variables so users don't need to use 'this' - // Tell SonarCloud to ignore these as user code may need them - const self = this // NOSONAR needed for $emit - const screen = this.screen //NOSONAR - const screenValues = this.screenValues //NOSONAR - const screenTimeZone = this.screenTimeZone //NOSONAR - const api = this.api //NOSONAR - const runScript = this.runScript //NOSONAR + const self = this + const screen = this.screen + const screenValues = this.screenValues + const screenTimeZone = this.screenTimeZone + const api = this.api + const runScript = this.runScript + if ( + self || + screen || + screenValues || + screenTimeZone || + api || + runScript + ) { + // Add a noop to preserve the variables in the if statement + // from being removed by compiler optimzations + this.$nextTick(() => {}) + } for (let i = 0; i < lines.length; i++) { try { const result = eval(lines[i].trim()) @@ -114,13 +125,15 @@ export default { this.criticalCmdUser = error.object.data.instance_variables['@username'] this.displayCriticalCmd = true - } - if (error.message.includes('is Hazardous')) { + } else if (error.message.includes('is Hazardous')) { this.lastCmd = error.message.split('\n').pop() this.displaySendHazardous = true while (this.displaySendHazardous) { await new Promise((resolve) => setTimeout(resolve, 500)) } + } else { + // eslint-disable-next-line + console.error(error) } } } diff --git a/openc3/python/test/interfaces/test_mqtt_interface.py b/openc3/python/test/interfaces/test_mqtt_interface.py index 623b2db61..29b352a9c 100644 --- a/openc3/python/test/interfaces/test_mqtt_interface.py +++ b/openc3/python/test/interfaces/test_mqtt_interface.py @@ -30,7 +30,7 @@ def test_sets_all_the_instance_variables(self): i = MqttInterface("localhost", "1883") self.assertEqual(i.name, "MqttInterface") self.assertEqual(i.hostname, "localhost") - self.assertEqual(i.ssl, False) + self.assertFalse(i.ssl) self.assertEqual(i.port, 1883) self.assertEqual(i.ack_timeout, 5.0) diff --git a/openc3/python/test/interfaces/test_mqtt_stream_interface.py b/openc3/python/test/interfaces/test_mqtt_stream_interface.py index aeea80dae..befcf0945 100644 --- a/openc3/python/test/interfaces/test_mqtt_stream_interface.py +++ b/openc3/python/test/interfaces/test_mqtt_stream_interface.py @@ -30,7 +30,7 @@ def test_sets_all_the_instance_variables(self): i = MqttStreamInterface("localhost", "1883", False, "write_topic", "read_topic") self.assertEqual(i.name, "MqttStreamInterface") self.assertEqual(i.hostname, "localhost") - self.assertEqual(i.ssl, False) + self.assertFalse(i.ssl) self.assertEqual(i.port, 1883) self.assertEqual(i.write_topic, "write_topic") self.assertEqual(i.read_topic, "read_topic") diff --git a/openc3/python/test/interfaces/test_tcpip_server_interface.py b/openc3/python/test/interfaces/test_tcpip_server_interface.py index 540d68078..e8fd6145d 100644 --- a/openc3/python/test/interfaces/test_tcpip_server_interface.py +++ b/openc3/python/test/interfaces/test_tcpip_server_interface.py @@ -132,7 +132,7 @@ def test_server_read_only(self): sock.connect(server_address) buffer = b"\x00\x01\x02\x03" sock.sendall(buffer) - time.sleep(0.01) # Allow the data to be processed (thread switch) + time.sleep(0.1) # Allow the data to be processed (thread switch) self.assertEqual(i.read_queue_size(), 1) self.assertEqual(i.write_queue_size(), 0) packet = i.read() @@ -192,7 +192,7 @@ def send(): time.sleep(0.02) # Allow the data to be processed (thread switch) write_buffer = b"\x06\x07\x08\x09" sock.sendall(write_buffer) - time.sleep(0.01) + time.sleep(0.1) self.assertEqual(i.read_queue_size(), 1) self.assertEqual(i.write_queue_size(), 1) data = sock.recv(4096)