phug-php/util

View on GitHub

Showing 5 of 7 total issues

Method addModule has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function addModule($module)
    {
        if ($module instanceof ModuleInterface) {
            if (in_array($module, $this->modules, true)) {
                throw new InvalidArgumentException(
Severity: Minor
Found in Util/Partial/ModuleContainerTrait.php - About 1 hr to fix

    Function __call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function __call($method, $parameters)
        {
            if ($this instanceof OptionInterface && $this->hasOption('macros')) {
                $macros = $this->getOption('macros') ?: [];
                if (isset($macros[$method])) {
    Severity: Minor
    Found in Util/Partial/MacroableTrait.php - About 55 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 addModule has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function addModule($module)
        {
            if ($module instanceof ModuleInterface) {
                if (in_array($module, $this->modules, true)) {
                    throw new InvalidArgumentException(
    Severity: Minor
    Found in Util/Partial/ModuleContainerTrait.php - About 55 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 withVariableReference has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private function withVariableReference(&$variable, $name, $callback)
        {
            $keys = $this->handleOptionName($name);
            if (is_array($keys)) {
                foreach (array_slice($keys, 0, -1) as $key) {
    Severity: Minor
    Found in Util/Partial/OptionTrait.php - About 55 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 addAll has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        #[ReturnTypeWillChange]
        public function addAll($storage)
        {
            if ($storage && $this->holder instanceof AttributesOrderInterface) {
                foreach ($storage as $element) {
    Severity: Minor
    Found in Util/AttributesStorage.php - About 35 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