{"results":{"result":{"added-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-url":"https://github.com/hathach/tinyusb/pull/3326","old-code-health":6.170402193056757,"modified-files":{"code-health":6.147946520689056,"old-code-health":6.170402193056757,"files":[{"file":"examples/host/cdc_msc_hid/src/msc_app.c","loc":26,"old-loc":25,"code-health":10.0,"old-code-health":10.0},{"file":"examples/host/cdc_msc_hid_freertos/src/msc_app.c","loc":31,"old-loc":30,"code-health":10.0,"old-code-health":10.0},{"file":"examples/host/msc_file_explorer/src/main.c","loc":38,"old-loc":39,"code-health":10.0,"old-code-health":10.0},{"file":"src/class/net/ncm_device.c","loc":575,"old-loc":578,"code-health":7.261510501459621,"old-code-health":7.261510501459621},{"file":"src/portable/ehci/ehci.c","loc":650,"old-loc":650,"code-health":7.252686033268628,"old-code-health":7.252686033268628},{"file":"src/portable/ohci/ohci.c","loc":479,"old-loc":479,"code-health":8.816158827775617,"old-code-health":8.816158827775617},{"file":"examples/device/audio_4_channel_mic/src/usb_descriptors.c","loc":93,"old-loc":89,"code-health":10.0,"old-code-health":10.0},{"file":"examples/device/cdc_msc/src/main.c","loc":82,"old-loc":82,"code-health":10.0,"old-code-health":10.0},{"file":"src/class/video/video_device.c","loc":1129,"old-loc":1079,"code-health":4.047481214642374,"old-code-health":4.055227268985362},{"file":"src/host/usbh.c","loc":1403,"old-loc":1403,"code-health":4.319622020038634,"old-code-health":4.319622020038634},{"file":"examples/device/cdc_uac2/src/cdc_app.c","loc":27,"old-loc":34,"code-health":10.0,"old-code-health":10.0},{"file":"examples/host/cdc_msc_hid_freertos/src/cdc_app.c","loc":74,"old-loc":72,"code-health":9.387218218812514,"old-code-health":9.387218218812514},{"file":"hw/bsp/board.c","loc":144,"old-loc":145,"code-health":10.0,"old-code-health":10.0},{"file":"src/portable/synopsys/dwc2/dcd_dwc2.c","loc":719,"old-loc":719,"code-health":6.650935738613568,"old-code-health":6.650935738613568}]},"removed-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-id":"3326","analysis-time":"2025-11-03T13:47:02Z","negative-impact-count":2,"suppressions":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"affected-hotspots":2,"commits":["bda7efb1b3d482b7add2535a4a72f51a0dea5c08","8e9ba218157eb1777872319ce3031ba5be6d7ccc","67b2a5c2e1dacd305015ae4a6329c8db8f198e81","00f374682ea5aaecf189e46966f015576049a773","22f01aea0d31b5a54532877d02d61f51041aeb6f","47650d4a1afa74fa9584da2377e08041844a3a9b"],"is-negative-review":true,"negative-findings":{"number-of-types":1,"number-of-files-touched":1,"findings":[{"method":"handle_video_stm_cs_req","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the C language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"src/class/video/video_device.c","refactoring-examples":[{"architectural-component-id":null,"author-name":"hathach","training-data":{"loc-added":"56","loc-deleted":"50","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.494","delta-n-functions":"0","current-file-score":"9.6882083290695"},"author-email":"thach@tinyusb.org","commit-full-message":"add -Wno-error=format for espressif\nwrap up cdc_msc_hid_freertos","commit-date":"2023-09-26T12:09:36Z","current-rev":"f6ca86c3d","filename":"tinyusb/hw/bsp/nrf/family.c","previous-rev":"a7c136c03","commit-title":"tested cdc_msc_hid_freertos with samd51","language":"C","id":"9aa6bf46ecc8de9e66375157db1f153c3928a576","model-score":0.22,"author-id":null,"project-id":37161,"delta-file-score":0.44580856,"diff":"diff --git a/hw/bsp/nrf/family.c b/hw/bsp/nrf/family.c\nindex 6fcfd9476..3620bc8cc 100644\n--- a/hw/bsp/nrf/family.c\n+++ b/hw/bsp/nrf/family.c\n@@ -97,9 +97,4 @@ TU_ATTR_UNUSED static void power_event_handler(nrfx_power_usb_evt_t event) {\n #if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421\n+static void max3421_init(void);\n static nrfx_spim_t _spi = NRFX_SPIM_INSTANCE(1);\n-\n-void max3421_int_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {\n-  if (!(pin == MAX3421_INTR_PIN && action == NRF_GPIOTE_POLARITY_HITOLO)) return;\n-\n-  tuh_int_handler(1);\n-}\n #endif\n@@ -193,46 +188,3 @@ void board_init(void) {\n #if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421\n-  // MAX3421 need 3.3v signal (may not be needed)\n-  #if defined(UICR_REGOUT0_VOUT_Msk) && 0\n-  if ((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) != UICR_REGOUT0_VOUT_3V3) {\n-    NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;\n-    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}\n-\n-    NRF_UICR->REGOUT0 = (NRF_UICR->REGOUT0 & ~UICR_REGOUT0_VOUT_Msk) | UICR_REGOUT0_VOUT_3V3;\n-\n-    NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;\n-    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}\n-\n-    NVIC_SystemReset();\n-  }\n-  #endif\n-\n-  // manually manage CS\n-  nrf_gpio_cfg_output(MAX3421_CS_PIN);\n-  nrf_gpio_pin_write(MAX3421_CS_PIN, 1);\n-\n-  // USB host using max3421e usb controller via SPI\n-  nrfx_spim_config_t cfg = {\n-      .sck_pin        = MAX3421_SCK_PIN,\n-      .mosi_pin       = MAX3421_MOSI_PIN,\n-      .miso_pin       = MAX3421_MISO_PIN,\n-      .ss_pin         = NRFX_SPIM_PIN_NOT_USED,\n-      .ss_active_high = false,\n-      .irq_priority   = 3,\n-      .orc            = 0xFF,\n-      // default setting 4 Mhz, Mode 0, MSB first\n-      .frequency      = NRF_SPIM_FREQ_4M,\n-      .mode           = NRF_SPIM_MODE_0,\n-      .bit_order      = NRF_SPIM_BIT_ORDER_MSB_FIRST,\n-  };\n-\n-  // no handler --> blocking\n-  nrfx_spim_init(&_spi, &cfg, NULL, NULL);\n-\n-  // max3421e interrupt pin\n-  nrfx_gpiote_init(1);\n-  nrfx_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(true);\n-  in_config.pull = NRF_GPIO_PIN_PULLUP;\n-\n-  nrfx_gpiote_in_init(MAX3421_INTR_PIN, &in_config, max3421_int_handler);\n-  nrfx_gpiote_trigger_enable(MAX3421_INTR_PIN, true);\n+  max3421_init();\n #endif\n@@ -319,2 +271,56 @@ void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info) {\n \n+void max3421_int_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {\n+  if (!(pin == MAX3421_INTR_PIN && action == NRF_GPIOTE_POLARITY_HITOLO)) return;\n+  tuh_int_handler(1);\n+}\n+\n+static void max3421_init(void) {\n+  // MAX3421 need 3.3v signal (may not be needed)\n+//  #if defined(UICR_REGOUT0_VOUT_Msk)\n+//  if ((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) != UICR_REGOUT0_VOUT_3V3) {\n+//    NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;\n+//    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}\n+//\n+//    NRF_UICR->REGOUT0 = (NRF_UICR->REGOUT0 & ~UICR_REGOUT0_VOUT_Msk) | UICR_REGOUT0_VOUT_3V3;\n+//\n+//    NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;\n+//    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}\n+//\n+//    NVIC_SystemReset();\n+//  }\n+//  #endif\n+\n+  // manually manage CS\n+  nrf_gpio_cfg_output(MAX3421_CS_PIN);\n+  nrf_gpio_pin_write(MAX3421_CS_PIN, 1);\n+\n+  // USB host using max3421e usb controller via SPI\n+  nrfx_spim_config_t cfg = {\n+      .sck_pin        = MAX3421_SCK_PIN,\n+      .mosi_pin       = MAX3421_MOSI_PIN,\n+      .miso_pin       = MAX3421_MISO_PIN,\n+      .ss_pin         = NRFX_SPIM_PIN_NOT_USED,\n+      .ss_active_high = false,\n+      .irq_priority   = 3,\n+      .orc            = 0xFF,\n+      // default setting 4 Mhz, Mode 0, MSB first\n+      .frequency      = NRF_SPIM_FREQ_4M,\n+      .mode           = NRF_SPIM_MODE_0,\n+      .bit_order      = NRF_SPIM_BIT_ORDER_MSB_FIRST,\n+  };\n+\n+  // no handler --> blocking\n+  nrfx_spim_init(&_spi, &cfg, NULL, NULL);\n+\n+  // max3421e interrupt pin\n+  nrfx_gpiote_init(1);\n+  nrfx_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(true);\n+  in_config.pull = NRF_GPIO_PIN_PULLUP;\n+\n+  NVIC_SetPriority(GPIOTE_IRQn, 2);\n+\n+  nrfx_gpiote_in_init(MAX3421_INTR_PIN, &in_config, max3421_int_handler);\n+  nrfx_gpiote_trigger_enable(MAX3421_INTR_PIN, true);\n+}\n+\n void tuh_max3421_int_api(uint8_t rhport, bool enabled) {\n","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":1042,"what-changed":"handle_video_stm_cs_req already has high cyclomatic complexity, and now it increases in Lines of Code from 126 to 128","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"degraded"},{"method":"_update_streaming_parameters","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the C language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"src/class/video/video_device.c","refactoring-examples":[{"architectural-component-id":null,"author-name":"hathach","training-data":{"loc-added":"56","loc-deleted":"50","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.494","delta-n-functions":"0","current-file-score":"9.6882083290695"},"author-email":"thach@tinyusb.org","commit-full-message":"add -Wno-error=format for espressif\nwrap up cdc_msc_hid_freertos","commit-date":"2023-09-26T12:09:36Z","current-rev":"f6ca86c3d","filename":"tinyusb/hw/bsp/nrf/family.c","previous-rev":"a7c136c03","commit-title":"tested cdc_msc_hid_freertos with samd51","language":"C","id":"9aa6bf46ecc8de9e66375157db1f153c3928a576","model-score":0.22,"author-id":null,"project-id":37161,"delta-file-score":0.44580856,"diff":"diff --git a/hw/bsp/nrf/family.c b/hw/bsp/nrf/family.c\nindex 6fcfd9476..3620bc8cc 100644\n--- a/hw/bsp/nrf/family.c\n+++ b/hw/bsp/nrf/family.c\n@@ -97,9 +97,4 @@ TU_ATTR_UNUSED static void power_event_handler(nrfx_power_usb_evt_t event) {\n #if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421\n+static void max3421_init(void);\n static nrfx_spim_t _spi = NRFX_SPIM_INSTANCE(1);\n-\n-void max3421_int_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {\n-  if (!(pin == MAX3421_INTR_PIN && action == NRF_GPIOTE_POLARITY_HITOLO)) return;\n-\n-  tuh_int_handler(1);\n-}\n #endif\n@@ -193,46 +188,3 @@ void board_init(void) {\n #if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421\n-  // MAX3421 need 3.3v signal (may not be needed)\n-  #if defined(UICR_REGOUT0_VOUT_Msk) && 0\n-  if ((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) != UICR_REGOUT0_VOUT_3V3) {\n-    NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;\n-    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}\n-\n-    NRF_UICR->REGOUT0 = (NRF_UICR->REGOUT0 & ~UICR_REGOUT0_VOUT_Msk) | UICR_REGOUT0_VOUT_3V3;\n-\n-    NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;\n-    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}\n-\n-    NVIC_SystemReset();\n-  }\n-  #endif\n-\n-  // manually manage CS\n-  nrf_gpio_cfg_output(MAX3421_CS_PIN);\n-  nrf_gpio_pin_write(MAX3421_CS_PIN, 1);\n-\n-  // USB host using max3421e usb controller via SPI\n-  nrfx_spim_config_t cfg = {\n-      .sck_pin        = MAX3421_SCK_PIN,\n-      .mosi_pin       = MAX3421_MOSI_PIN,\n-      .miso_pin       = MAX3421_MISO_PIN,\n-      .ss_pin         = NRFX_SPIM_PIN_NOT_USED,\n-      .ss_active_high = false,\n-      .irq_priority   = 3,\n-      .orc            = 0xFF,\n-      // default setting 4 Mhz, Mode 0, MSB first\n-      .frequency      = NRF_SPIM_FREQ_4M,\n-      .mode           = NRF_SPIM_MODE_0,\n-      .bit_order      = NRF_SPIM_BIT_ORDER_MSB_FIRST,\n-  };\n-\n-  // no handler --> blocking\n-  nrfx_spim_init(&_spi, &cfg, NULL, NULL);\n-\n-  // max3421e interrupt pin\n-  nrfx_gpiote_init(1);\n-  nrfx_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(true);\n-  in_config.pull = NRF_GPIO_PIN_PULLUP;\n-\n-  nrfx_gpiote_in_init(MAX3421_INTR_PIN, &in_config, max3421_int_handler);\n-  nrfx_gpiote_trigger_enable(MAX3421_INTR_PIN, true);\n+  max3421_init();\n #endif\n@@ -319,2 +271,56 @@ void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info) {\n \n+void max3421_int_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {\n+  if (!(pin == MAX3421_INTR_PIN && action == NRF_GPIOTE_POLARITY_HITOLO)) return;\n+  tuh_int_handler(1);\n+}\n+\n+static void max3421_init(void) {\n+  // MAX3421 need 3.3v signal (may not be needed)\n+//  #if defined(UICR_REGOUT0_VOUT_Msk)\n+//  if ((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) != UICR_REGOUT0_VOUT_3V3) {\n+//    NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;\n+//    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}\n+//\n+//    NRF_UICR->REGOUT0 = (NRF_UICR->REGOUT0 & ~UICR_REGOUT0_VOUT_Msk) | UICR_REGOUT0_VOUT_3V3;\n+//\n+//    NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;\n+//    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}\n+//\n+//    NVIC_SystemReset();\n+//  }\n+//  #endif\n+\n+  // manually manage CS\n+  nrf_gpio_cfg_output(MAX3421_CS_PIN);\n+  nrf_gpio_pin_write(MAX3421_CS_PIN, 1);\n+\n+  // USB host using max3421e usb controller via SPI\n+  nrfx_spim_config_t cfg = {\n+      .sck_pin        = MAX3421_SCK_PIN,\n+      .mosi_pin       = MAX3421_MOSI_PIN,\n+      .miso_pin       = MAX3421_MISO_PIN,\n+      .ss_pin         = NRFX_SPIM_PIN_NOT_USED,\n+      .ss_active_high = false,\n+      .irq_priority   = 3,\n+      .orc            = 0xFF,\n+      // default setting 4 Mhz, Mode 0, MSB first\n+      .frequency      = NRF_SPIM_FREQ_4M,\n+      .mode           = NRF_SPIM_MODE_0,\n+      .bit_order      = NRF_SPIM_BIT_ORDER_MSB_FIRST,\n+  };\n+\n+  // no handler --> blocking\n+  nrfx_spim_init(&_spi, &cfg, NULL, NULL);\n+\n+  // max3421e interrupt pin\n+  nrfx_gpiote_init(1);\n+  nrfx_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(true);\n+  in_config.pull = NRF_GPIO_PIN_PULLUP;\n+\n+  NVIC_SetPriority(GPIOTE_IRQn, 2);\n+\n+  nrfx_gpiote_in_init(MAX3421_INTR_PIN, &in_config, max3421_int_handler);\n+  nrfx_gpiote_trigger_enable(MAX3421_INTR_PIN, true);\n+}\n+\n void tuh_max3421_int_api(uint8_t rhport, bool enabled) {\n","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":460,"what-changed":"_update_streaming_parameters already has high cyclomatic complexity, and now it increases in Lines of Code from 79 to 83","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"degraded"}]},"positive-impact-count":0,"repo":"tinyusb","code-health":6.147946520689056,"version":"3.0","authors":["hathach"],"directives":{"added":[],"removed":[]},"positive-findings":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"notices":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"external-review-provider":"GitHub"},"analysistime":"2025-11-03T13:47:02.000Z","project-name":"tinyusb","repository":"https://github.com/hathach/tinyusb.git"}}