{"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":7.039661338871438,"modified-files":{"code-health":7.034133596152259,"old-code-health":7.039661338871438,"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/common/tusb_fifo.c","loc":511,"old-loc":515,"code-health":7.657673398248461,"old-code-health":7.657673398248461},{"file":"src/device/usbd.c","loc":1118,"old-loc":1116,"code-health":5.1514435607575155,"old-code-health":5.140918220220686},{"file":"src/portable/synopsys/dwc2/dcd_dwc2.c","loc":726,"old-loc":719,"code-health":6.704987341569798,"old-code-health":6.650935738613568},{"file":"examples/device/audio_4_channel_mic/src/main.c","loc":229,"old-loc":225,"code-health":8.852066566277504,"old-code-health":8.852066566277504},{"file":"examples/device/audio_4_channel_mic_freertos/src/usb_descriptors.c","loc":93,"old-loc":89,"code-health":10.0,"old-code-health":10.0},{"file":"examples/device/audio_test/src/main.c","loc":227,"old-loc":223,"code-health":8.852066566277504,"old-code-health":8.852066566277504},{"file":"examples/device/audio_test/src/usb_descriptors.c","loc":94,"old-loc":90,"code-health":10.0,"old-code-health":10.0},{"file":"examples/device/audio_test_freertos/src/usb_descriptors.c","loc":94,"old-loc":90,"code-health":10.0,"old-code-health":10.0},{"file":"examples/device/audio_test_multi_rate/src/main.c","loc":385,"old-loc":381,"code-health":7.288058700638796,"old-code-health":7.288058700638796},{"file":"examples/device/audio_test_multi_rate/src/usb_descriptors.c","loc":124,"old-loc":120,"code-health":10.0,"old-code-health":10.0},{"file":"examples/device/cdc_dual_ports/src/main.c","loc":92,"old-loc":86,"code-health":9.92101847124095,"old-code-health":9.92101847124095},{"file":"examples/device/cdc_uac2/src/uac2_app.c","loc":205,"old-loc":201,"code-health":9.313614294706117,"old-code-health":9.313614294706117},{"file":"examples/device/cdc_uac2/src/usb_descriptors.c","loc":144,"old-loc":140,"code-health":10.0,"old-code-health":10.0},{"file":"examples/device/dfu/src/usb_descriptors.c","loc":96,"old-loc":92,"code-health":10.0,"old-code-health":10.0},{"file":"examples/device/dfu_runtime/src/main.c","loc":60,"old-loc":58,"code-health":10.0,"old-code-health":10.0},{"file":"examples/device/dfu_runtime/src/usb_descriptors.c","loc":93,"old-loc":89,"code-health":10.0,"old-code-health":10.0},{"file":"examples/device/dynamic_configuration/src/main.c","loc":110,"old-loc":111,"code-health":9.387218218812514,"old-code-health":9.387218218812514},{"file":"examples/device/dynamic_configuration/src/msc_disk.c","loc":133,"old-loc":131,"code-health":9.6882083290695,"old-code-health":9.6882083290695},{"file":"examples/device/dynamic_configuration/src/usb_descriptors.c","loc":144,"old-loc":140,"code-health":10.0,"old-code-health":10.0},{"file":"examples/device/hid_boot_interface/src/main.c","loc":128,"old-loc":143,"code-health":8.747566364082143,"old-code-health":8.747566364082143},{"file":"examples/device/hid_boot_interface/src/usb_descriptors.c","loc":88,"old-loc":97,"code-health":10.0,"old-code-health":10.0},{"file":"examples/device/hid_composite/src/main.c","loc":180,"old-loc":201,"code-health":8.972017705099022,"old-code-health":8.926613172271683},{"file":"src/device/usbd_control.c","loc":115,"old-loc":115,"code-health":9.92101847124095,"old-code-health":9.92101847124095},{"file":"src/tusb.c","loc":431,"old-loc":429,"code-health":7.894164582114826,"old-code-health":7.894164582114826}]},"removed-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-id":"3326","analysis-time":"2025-11-05T08:31:20Z","negative-impact-count":2,"suppressions":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"affected-hotspots":3,"commits":["bda7efb1b3d482b7add2535a4a72f51a0dea5c08","8e9ba218157eb1777872319ce3031ba5be6d7ccc","67b2a5c2e1dacd305015ae4a6329c8db8f198e81","00f374682ea5aaecf189e46966f015576049a773","22f01aea0d31b5a54532877d02d61f51041aeb6f","8979af34c0e5b97520070bcfdffe5280de9ac24c","93a7ca05ca83f19d568673813fd596099bc17bfd"],"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":3,"repo":"tinyusb","code-health":7.034133596152259,"version":"3.0","authors":["hathach"],"directives":{"added":[],"removed":[]},"positive-findings":{"number-of-types":2,"number-of-files-touched":2,"findings":[{"method":"process_control_request","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/device/usbd.c","change-level":"improvement","is-hotspot?":true,"line":782,"what-changed":"process_control_request decreases in cyclomatic complexity from 44 to 43, threshold = 9","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":"improved"},{"method":"edpt_disable","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/portable/synopsys/dwc2/dcd_dwc2.c","change-level":"improvement","is-hotspot?":true,"line":283,"what-changed":"edpt_disable decreases in cyclomatic complexity from 14 to 11, threshold = 9","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":"improved"},{"name":"Overall Code Complexity","file":"src/portable/synopsys/dwc2/dcd_dwc2.c","change-type":"improved","change-level":"improvement","is-hotspot?":true,"why-it-occurs":"Overall Code Complexity is measured by the mean cyclomatic complexity across all functions in the file. The lower the number, the better.\n\nCyclomatic complexity is a function level metric that measures the number of logical branches (if-else, loops, etc.). Cyclomatic complexity is a rough complexity measure, but useful as a way of estimating the minimum number of unit tests you would need. As such, prefer functions with low cyclomatic complexity (2-3 branches).","how-to-fix":"You address the overall cyclomatic complexity by a) modularizing the code, and b) abstract away the complexity. Let's look at some examples:\n\nModularizing the Code: Do an X-Ray and inspect the local hotspots. Are there any complex conditional expressions? If yes, then do a [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring. Extract the conditional logic into a separate function and put a good name on that function. This clarifies the intent and makes the original function easier to read. Repeat until all complex conditional expressions have been simplified.\n\n","what-changed":"The mean cyclomatic complexity decreases from 4.21 to 4.05, threshold = 4"}]},"notices":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"external-review-provider":"GitHub"},"analysistime":"2025-11-05T08:31:19.000Z","project-name":"tinyusb","repository":"https://github.com/hathach/tinyusb.git"}}