Avoid using static access to class 'mainaero\yii\gtm\widget\GTM' in method 'testShouldReturnRenderedDataPushSnippet'. Open
GTM::widget(['type' => 'dataLayerPush'])
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'mainaero\yii\gtm\widget\GTM' in method 'testShouldReturnEmptyStringIfNoDataLayerPushItems'. Open
$this->assertEquals('', GTM::widget(['type' => 'dataLayerPush']));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Define a constant instead of duplicating this literal "gtm_env" 6 times. Open
'gtm_env' => '>m_auth=<TOKEN>w>m_preview=<ENV_ID>>m_cookies_win=x',
- Read upRead up
- Exclude checks
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.
Define a constant instead of duplicating this literal ">m_auth=<token>w&gtm_preview=<env_id>&gtm_cookies_win=x" 4 times.</env_id></token> Open
'gtm_env' => '>m_auth=<TOKEN>w>m_preview=<ENV_ID>>m_cookies_win=x',
- Read upRead up
- Exclude checks
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.
Define a constant instead of duplicating this literal "gtm_id" 6 times. Open
'gtm_id' => '1A2B3CD'
- Read upRead up
- Exclude checks
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.
Define a constant instead of duplicating this literal "1A2B3CD" 6 times. Open
'gtm_id' => '1A2B3CD'
- Read upRead up
- Exclude checks
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.
Multi-line function call not indented correctly; expected 12 spaces but found 10 Open
$this->widget::widget(['type' => 'noscript'])
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
);
- Exclude checks
Multi-line function call not indented correctly; expected 14 spaces but found 12 Open
[
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 10 Open
'src/widget/views/dataLayerPush.php',
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
);
- Exclude checks
Multi-line function call not indented correctly; expected 14 spaces but found 12 Open
]
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
);
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 10 Open
'src/widget/views/dataLayerPush.php',
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 10 Open
[
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 10 Open
$this->widget->widget()
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 10 Open
),
- Exclude checks
Multi-line function call not indented correctly; expected 16 spaces but found 14 Open
]
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 6 Open
);
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 10 Open
$this->renderer->renderPhpFile(
- Exclude checks
Multi-line function call not indented correctly; expected 14 spaces but found 12 Open
[
- Exclude checks
Multi-line function call not indented correctly; expected 14 spaces but found 12 Open
]
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 10 Open
$this->renderer->renderPhpFile(
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 10 Open
]
- Exclude checks
Multi-line function call not indented correctly; expected 14 spaces but found 12 Open
'src/widget/views/script.php',
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 8 Open
$this->renderer->renderPhpFile(
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 10 Open
]
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
];
- Exclude checks
Multi-line function call not indented correctly; expected 16 spaces but found 14 Open
'src/widget/views/script.php',
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
];
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 6 Open
);
- Exclude checks
Multi-line function call not indented correctly; expected 16 spaces but found 14 Open
[
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 10 Open
),
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 10 Open
[
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 8 Open
),
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 8 Open
GTM::widget(['type' => 'dataLayerPush'])
- Exclude checks
Multi-line function call not indented correctly; expected 14 spaces but found 12 Open
'src/widget/views/noscript.php',
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 6 Open
);
- Exclude checks