squirrelphp/strings

View on GitHub

Showing 6 of 8 total issues

Method buildForm has 87 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        // Modify data before it is submitted/validated
        $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use ($options): void {
            // Retrieve submitted content
Severity: Major
Found in src/Attribute/StringFilterExtension.php - About 3 hrs to fix

    Function process has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function process(object $class): void
        {
            // Get class reflection data
            $annotationClass = new \ReflectionClass($class);
    
    
    Severity: Minor
    Found in src/Attribute/StringFilterProcessor.php - 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 filterScalarOrArray has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        private function filterScalarOrArray(mixed $propertyValue, array $stringFilters): string|array
        {
            if (
                (!\is_array($propertyValue) && !\is_scalar($propertyValue))
                || \is_bool($propertyValue)
    Severity: Minor
    Found in src/Attribute/StringFilterProcessor.php - 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

    Method replaceArrayWithCallback has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            string|array $pattern,
            callable $callback,
            array $subject,
            int $limit = -1,
            int $flags = 0,
    Severity: Minor
    Found in src/Regex.php - About 35 mins to fix

      Method replaceWithCallback has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              string|array $pattern,
              callable $callback,
              string $subject,
              int $limit = -1,
              int $flags = 0,
      Severity: Minor
      Found in src/Regex.php - About 35 mins to fix

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

            public function __construct(
                string|array $names,
                string ...$moreNames,
            ) {
                if (\is_string($names)) {
        Severity: Minor
        Found in src/Attribute/StringFilter.php - 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