{"results":{"result":{"added-files":{"code-health":9.584183791337065,"old-code-health":0.0,"files":[{"file":"src/Paramore.Brighter/Extensions/DictionaryExtensions.cs","loc":18,"code-health":10.0},{"file":"src/Paramore.Brighter/Extensions/RequestContextExtensions.cs","loc":38,"code-health":9.387218218812514}]},"external-review-url":"https://github.com/BrighterCommand/Brighter/pull/3678","old-code-health":9.533163180136178,"modified-files":{"code-health":9.78463374004698,"old-code-health":9.533163180136178,"files":[{"file":"src/Paramore.Brighter/MessageMappers/CloudEventJsonMessageMapper.cs","loc":100,"old-loc":87,"code-health":10.0,"old-code-health":10.0},{"file":"src/Paramore.Brighter/MessageMappers/JsonMessageMapper.cs","loc":57,"old-loc":45,"code-health":10.0,"old-code-health":10.0},{"file":"src/Paramore.Brighter/RequestContext.cs","loc":47,"old-loc":46,"code-health":10.0,"old-code-health":10.0},{"file":"src/Paramore.Brighter.Transformers.JustSaying/JustSayingMessageMapper.cs","loc":173,"old-loc":158,"code-health":10.0,"old-code-health":10.0},{"file":"src/Paramore.Brighter.Transformers.MassTransit/MassTransitMessageMapper.cs","loc":163,"old-loc":167,"code-health":9.387218218812514,"old-code-health":9.387218218812514},{"file":"src/Paramore.Brighter/Publication.cs","loc":29,"old-loc":28,"code-health":10.0,"old-code-health":10.0},{"file":"src/Paramore.Brighter/Transforms/Transformers/CloudEventsTransformer.cs","loc":235,"old-loc":238,"code-health":9.6882083290695,"old-code-health":8.921584214214416}]},"removed-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-id":"3678","analysis-time":"2025-07-28T10:33:08Z","negative-impact-count":2,"suppressions":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"affected-hotspots":0,"commits":["f6a98eb4a48e3300fa39a53a2d151b8374fded09","9b718e4c4cf3f89224aefa79a2eea5ad4ef7a992","0927af6541fd331fc9af94d613d4ca60b3b974a7","f0d52c83fa9f64f50ad65b8400f26929caabb8dc","a09656c0a99609cd9cb892fe767b85edd802ec12","8687305f82c6c970f3d5e7e02fedb93f76e0f9ec","37159339f490482338ffc0ac5479adc72304a339"],"is-negative-review":true,"negative-findings":{"number-of-types":1,"number-of-files-touched":1,"findings":[{"method":"GetHeaders","why-it-occurs":"A complex conditional is an expression inside a branch such as an <code>if</code>-statmeent which consists of multiple, logical operations. Example: <code>if (x.started() && y.running())</code>.Complex conditionals make the code even harder to read, and contribute to the Complex Method code smell. Encapsulate them.","name":"Complex Conditional","file":"src/Paramore.Brighter/Extensions/RequestContextExtensions.cs","refactoring-examples":[{"diff":"diff --git a/complex_conditional.js b/complex_conditional.js\nindex c43da09584..94259ce874 100644\n--- a/complex_conditional.js\n+++ b/complex_conditional.js\n@@ -1,16 +1,34 @@\n function messageReceived(message, timeReceived) {\n-   // Ignore all messages which aren't from known customers:\n-   if (!message.sender &&\n-       customers.getId(message.name) == null) {\n+   // Refactoring #1: encapsulate the business rule in a\n+   // function. A clear name replaces the need for the comment:\n+   if (!knownCustomer(message)) {\n      log('spam received -- ignoring');\n      return;\n    }\n \n-  // Provide an auto-reply when outside business hours:\n-  if ((timeReceived.getHours() > 17) ||\n-      (timeReceived.getHours() < 8)) {\n+  // Refactoring #2: encapsulate the business rule.\n+  // Again, note how a clear function name replaces the\n+  // need for a code comment:\n+  if (outsideBusinessHours(timeReceived)) {\n     return autoReplyTo(message);\n   }\n \n   pingAgentFor(message);\n+}\n+\n+function outsideBusinessHours(timeReceived) {\n+  // Refactoring #3: replace magic numbers with\n+  // symbols that communicate with the code reader:\n+  const closingHour = 17;\n+  const openingHour = 8;\n+\n+  const hours = timeReceived.getHours();\n+\n+  // Refactoring #4: simple conditional rules can\n+  // be further clarified by introducing a variable:\n+  const afterClosing = hours > closingHour;\n+  const beforeOpening = hours < openingHour;\n+\n+  // Yeah -- look how clear the business rule is now!\n+  return afterClosing || beforeOpening;\n }\n\\ No newline at end of file\n","language":"c#","improvement-type":"Complex Conditional"}],"change-level":"warning","is-hotspot?":false,"line":99,"what-changed":"GetHeaders has 1 complex conditionals with 2 branches, threshold = 2","how-to-fix":"Apply the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring so that the complex conditional is encapsulated in a separate function with a good name that captures the business rule. Optionally, for simple expressions, introduce a new variable which holds the result of the complex conditional.","change-type":"introduced"},{"method":"GetCloudEventAdditionalProperties","why-it-occurs":"A complex conditional is an expression inside a branch such as an <code>if</code>-statmeent which consists of multiple, logical operations. Example: <code>if (x.started() && y.running())</code>.Complex conditionals make the code even harder to read, and contribute to the Complex Method code smell. Encapsulate them.","name":"Complex Conditional","file":"src/Paramore.Brighter/Extensions/RequestContextExtensions.cs","refactoring-examples":[{"diff":"diff --git a/complex_conditional.js b/complex_conditional.js\nindex c43da09584..94259ce874 100644\n--- a/complex_conditional.js\n+++ b/complex_conditional.js\n@@ -1,16 +1,34 @@\n function messageReceived(message, timeReceived) {\n-   // Ignore all messages which aren't from known customers:\n-   if (!message.sender &&\n-       customers.getId(message.name) == null) {\n+   // Refactoring #1: encapsulate the business rule in a\n+   // function. A clear name replaces the need for the comment:\n+   if (!knownCustomer(message)) {\n      log('spam received -- ignoring');\n      return;\n    }\n \n-  // Provide an auto-reply when outside business hours:\n-  if ((timeReceived.getHours() > 17) ||\n-      (timeReceived.getHours() < 8)) {\n+  // Refactoring #2: encapsulate the business rule.\n+  // Again, note how a clear function name replaces the\n+  // need for a code comment:\n+  if (outsideBusinessHours(timeReceived)) {\n     return autoReplyTo(message);\n   }\n \n   pingAgentFor(message);\n+}\n+\n+function outsideBusinessHours(timeReceived) {\n+  // Refactoring #3: replace magic numbers with\n+  // symbols that communicate with the code reader:\n+  const closingHour = 17;\n+  const openingHour = 8;\n+\n+  const hours = timeReceived.getHours();\n+\n+  // Refactoring #4: simple conditional rules can\n+  // be further clarified by introducing a variable:\n+  const afterClosing = hours > closingHour;\n+  const beforeOpening = hours < openingHour;\n+\n+  // Yeah -- look how clear the business rule is now!\n+  return afterClosing || beforeOpening;\n }\n\\ No newline at end of file\n","language":"c#","improvement-type":"Complex Conditional"}],"change-level":"warning","is-hotspot?":false,"line":143,"what-changed":"GetCloudEventAdditionalProperties has 1 complex conditionals with 2 branches, threshold = 2","how-to-fix":"Apply the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring so that the complex conditional is encapsulated in a separate function with a good name that captures the business rule. Optionally, for simple expressions, introduce a new variable which holds the result of the complex conditional.","change-type":"introduced"}]},"positive-impact-count":2,"repo":"Brighter","code-health":9.771581185247266,"version":"3.0","authors":["Rafael Andrade"],"directives":{"added":[],"removed":[]},"positive-findings":{"number-of-types":2,"number-of-files-touched":1,"findings":[{"method":"WritePublicationHeaders","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/Paramore.Brighter/Transforms/Transformers/CloudEventsTransformer.cs","change-level":"improvement","is-hotspot?":false,"line":202,"what-changed":"WritePublicationHeaders is no longer above the threshold for cyclomatic complexity","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":"fixed"},{"name":"Overall Code Complexity","file":"src/Paramore.Brighter/Transforms/Transformers/CloudEventsTransformer.cs","change-type":"fixed","change-level":"improvement","is-hotspot?":false,"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 in this module is no longer above the threshold"}]},"notices":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"external-review-provider":"GitHub"},"analysistime":"2025-07-28T10:33:07.000Z","project-name":"Brighter","repository":"https://github.com/BrighterCommand/Brighter.git"}}