cds-snc/elenchos

View on GitHub

Showing 6 of 14 total issues

Function pollLoadBalancer has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

export const pollLoadBalancer = async (
  clusterId: string,
  checkState: string = "active",
  reporter: (msg: string, status?: StatusMessage["state"]) => void = () => {}
): Promise<void> => {
Severity: Minor
Found in src/lib/loadBalancer/pollLoadBalancer.ts - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function pollCluster has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export const pollCluster = async (
  clusterId: string,
  checkState: string = "running",
  reporter: (msg: string, status?: StatusMessage["state"]) => void = () => {}
): Promise<void | { kubernetes_cluster: Cluster }> => {
Severity: Minor
Found in src/lib/cluster/pollCluster.ts - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function saveConfig has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const saveConfig = async (req: Request, refId: string, prState: string) => {
  //

  let deployment = await getDeployment({ refId: refId });

Severity: Minor
Found in src/lib/deploy/deployRelease.ts - About 1 hr to fix

    Function main has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const main = async (req: Request, res: Response) => {
      const refId = enforceRefId(req, res);
      const eventInfo = handleEvent(req);
      const defaultMessage = "✅ event received";
    
    
    Severity: Minor
    Found in src/routes/index.ts - About 1 hr to fix

      Function main has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export const main = async (req: Request, res: Response) => {
        const refId = enforceRefId(req, res);
        const eventInfo = handleEvent(req);
        const defaultMessage = "✅ event received";
      
      
      Severity: Minor
      Found in src/routes/index.ts - About 45 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function getRefId has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export const getRefId = (event: RequestBody): false | string => {
        let refId: false | string = false;
      
        if (!validateFields(event)) {
          return false;
      Severity: Minor
      Found in src/lib/util/getRefId.ts - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Severity
      Category
      Status
      Source
      Language