Repository: eslint/eslint
File: lib/rules/complexity.js (JavaScript)

Code before:
                                minimum: 0
                            },
                            modifiedComplexity: {
                                type: "boolean"
                            }
                        },
                        additionalProperties: false
                    }
                ]
            }
        ],

        messages: {
            complex: "{{name}} has a complexity of {{complexity}}. Maximum allowed is {{max}}."
        }
    },

    create(context) {
        const option = context.options[0];
        let THRESHOLD = 20;
        let IS_MODIFIED_COMPLEXITY = false;

        if (typeof option === "object") {
            if (Object.hasOwn(option, "maximum") || Object.hasOwn(option, "max")) {
                THRESHOLD = option.maximum || option.max;
            }

            if (Object.hasOwn(option, "modifiedComplexity")) {
                IS_MODIFIED_COMPLEXITY = option.modifiedComplexity;
            }
        } else if (typeof option === "number") {
            THRESHOLD = option;
        }

        //--------------------------------------------------------------------------
        // Helpers
        //--------------------------------------------------------------------------

        // Using a stack to store complexity per code path
        const complexities = [];

        /**
         * Increase the complexity of the code path in context
         * @returns {void}
         * @private
         */
        function increaseComplexity() {
            complexities[complexities.length - 1]++;
        }

        //--------------------------------------------------------------------------

Review comment (performance):
```suggestion
        let IS_MODIFIED_COMPLEXITY = false;

        if (typeof option === "object") {
            THRESHOLD = option?.maximum ?? option?.max ?? THRESHOLD;
            IS_MODIFIED_COMPLEXITY = option?.modifiedComplexity ?? IS_MODIFIED_COMPLEXITY;
        }
```

Code after:
                                minimum: 0
                            },
                            variant: {
                                enum: ["classic", "modified"]
                            }
                        },
                        additionalProperties: false
                    }
                ]
            }
        ],

        messages: {
            complex: "{{name}} has a complexity of {{complexity}}. Maximum allowed is {{max}}."
        }
    },

    create(context) {
        const option = context.options[0];
        let THRESHOLD = 20;
        let VARIANT = "classic";

        if (typeof option === "object") {
            if (Object.hasOwn(option, "maximum") || Object.hasOwn(option, "max")) {
                THRESHOLD = option.maximum || option.max;
            }

            if (Object.hasOwn(option, "variant")) {
                VARIANT = option.variant;
            }
        } else if (typeof option === "number") {
            THRESHOLD = option;
        }

        const IS_MODIFIED_COMPLEXITY = VARIANT === "modified";

        //--------------------------------------------------------------------------
        // Helpers
        //--------------------------------------------------------------------------

        // Using a stack to store complexity per code path
        const complexities = [];

        /**
         * Increase the complexity of the code path in context
         * @returns {void}
         * @private
         */
        function increaseComplexity() {
            complexities[complexities.length - 1]++;
        }