YetiForceCompany/YetiForcePDF

View on GitHub
lib/Style/Normalizer/BackgroundImage.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid unused parameters such as '$ruleName'.
Open

    public function normalize($ruleValue, string $ruleName = ''): array

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Define a constant instead of duplicating this literal "transparent" 3 times.
Open

        if (null === $this->normalized && 'transparent' !== $ruleValue) {

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Spaces must be used to indent lines; tabs are not allowed
Open

            return $this->normalized = ['background-image' => $ruleValue];

Spaces must be used to indent lines; tabs are not allowed
Open

            return $this->normalized = ['background-image' => 'transparent'];

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        if (null === $this->normalized && 'transparent' !== $ruleValue) {

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

        return $this->normalized;

Spaces must be used to indent lines; tabs are not allowed
Open

        if ('transparent' === $ruleValue) {

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    public function normalize($ruleValue, string $ruleName = ''): array

There are no issues that match your filters.

Category
Status