From 5ec7762b8591542b927682632f755dbb4aba7931 Mon Sep 17 00:00:00 2001
From: lukken <lukken@astron.nl>
Date: Wed, 26 Jan 2022 10:50:23 +0000
Subject: [PATCH] L2SS-584: Add xenon code complexity analysis with soft fail

---
 .gitlab-ci.yml                                           | 9 +++++++++
 .../tangostationcontrol/devices/sdp/xst.py               | 4 ++--
 tangostationcontrol/test-requirements.txt                | 1 +
 tangostationcontrol/tox.ini                              | 4 ++++
 4 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0dc48fd58..2ede84fb8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -361,6 +361,15 @@ bandit:
   script:
     - cd tangostationcontrol
     - tox -e bandit
+xenon:
+  stage: static-analysis
+  allow_failure: true
+  before_script:
+    - sudo apt-get update
+    - sudo apt-get install -y git
+  script:
+   - cd tangostationcontrol
+   - tox -e xenon
 shellcheck:
   stage: static-analysis
   before_script:
diff --git a/tangostationcontrol/tangostationcontrol/devices/sdp/xst.py b/tangostationcontrol/tangostationcontrol/devices/sdp/xst.py
index c0b6f7a98..3b0f59d24 100644
--- a/tangostationcontrol/tangostationcontrol/devices/sdp/xst.py
+++ b/tangostationcontrol/tangostationcontrol/devices/sdp/xst.py
@@ -108,8 +108,8 @@ class XST(Statistics):
     FPGA_xst_subband_select_RW = attribute_wrapper(comms_id=OPCUAConnection, comms_annotation=["FPGA_xst_subband_select_RW"], datatype=numpy.uint32, dims=(8,16), access=AttrWriteType.READ_WRITE)
     FPGA_xst_subband_select_R = attribute_wrapper(comms_id=OPCUAConnection, comms_annotation=["FPGA_xst_subband_select_R"], datatype=numpy.uint32, dims=(8,16))
 
-     FPGA_xst_offload_nof_crosslets_RW = attribute_wrapper(comms_id=OPCUAConnection, comms_annotation=["FPGA_xst_offload_nof_crosslets_RW"], datatype=numpy.uint32, dims=(16,), access=AttrWriteType.READ_WRITE)
-     FPGA_xst_offload_nof_crosslets_R = attribute_wrapper(comms_id=OPCUAConnection, comms_annotation=["FPGA_xst_offload_nof_crosslets_R"], datatype=numpy.uint32, dims=(16,))
+    FPGA_xst_offload_nof_crosslets_RW = attribute_wrapper(comms_id=OPCUAConnection, comms_annotation=["FPGA_xst_offload_nof_crosslets_RW"], datatype=numpy.uint32, dims=(16,), access=AttrWriteType.READ_WRITE)
+    FPGA_xst_offload_nof_crosslets_R = attribute_wrapper(comms_id=OPCUAConnection, comms_annotation=["FPGA_xst_offload_nof_crosslets_R"], datatype=numpy.uint32, dims=(16,))
 
     # number of packets with valid payloads
     nof_valid_payloads_R    = attribute_wrapper(comms_id=StatisticsClient, comms_annotation={"type": "statistics", "parameter": "nof_valid_payloads"}, dims=(XSTCollector.MAX_FPGAS,), datatype=numpy.uint64)
diff --git a/tangostationcontrol/test-requirements.txt b/tangostationcontrol/test-requirements.txt
index 16a9033db..6912d81e2 100644
--- a/tangostationcontrol/test-requirements.txt
+++ b/tangostationcontrol/test-requirements.txt
@@ -17,3 +17,4 @@ stestr>=3.0.0 # Apache-2.0
 testscenarios>=0.5.0 # Apache-2.0/BSD
 testtools>=2.4.0 # MIT
 timeout-decorator>=0.5  # MIT
+xenon>=0.8.0 # MIT
diff --git a/tangostationcontrol/tox.ini b/tangostationcontrol/tox.ini
index fc0876dd0..dfc758104 100644
--- a/tangostationcontrol/tox.ini
+++ b/tangostationcontrol/tox.ini
@@ -66,6 +66,10 @@ commands =
 commands =
     bandit -r devices/ -n5 -ll -s B104
 
+[testenv:xenon];
+commands =
+    xenon tangostationcontrol -b B -m A -a A
+
 [testenv:docs]
 deps =
     -r{toxinidir}/../docker-compose/lofar-device-base/lofar-requirements.txt
-- 
GitLab