Showing 89 of 122 total issues
Function getDefaultFiles
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function getDefaultFiles(): array
{
$defaultFiles = [
NotizConstants::TYPOSCRIPT_PATH . 'Channel/Channels.Default.typoscript',
NotizConstants::TYPOSCRIPT_PATH . 'Notification/Notifications.typoscript',
- Read upRead up
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 forceIdentifierForProperty
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected static function forceIdentifierForProperty(DataPreProcessor $processor, string $property, string $name = 'identifier')
{
$data = $processor->getData();
$data = is_array($data)
? $data
- Read upRead up
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 fetchSettingsClassName
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected static function fetchSettingsClassName(array $data): array
{
$channelClassName = $data['className'] ?? null;
if (class_exists($channelClassName)
- Read upRead up
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
The method transformDefinition uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$data['value'] = $value;
$data['path'] = $readablePath;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method compile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return parent::compile($argumentsName, $closureName, $initializationPhpCode, $node, $compiler);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method getChannels uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$channels = $definition->getChannels();
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method buildTcaArray() has 209 lines of code. Current threshold is set to 100. Avoid really long methods. Open
protected function buildTcaArray(): array
{
return [
'ctrl' => $this->getCtrl(),
- Exclude checks
The method formatEmailAddress uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return [
'name' => null,
'email' => $email,
];
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method getSlotViewFlexForm uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$flexForm = $this->buildSlotViewFlexForm($view);
$this->cacheService->set($hash, $flexForm);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method register uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$closure = function () use ($eventRunner) {
return call_user_func_array($eventRunner->getCallable(), func_get_args());
};
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method buildDefinition uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->cacheService->set(NotizConstants::CACHE_KEY_DEFINITION_OBJECT, $this->definitionObject);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method doLocalize uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
// Getting the file path and the localization key.
list($file, $key) = explode(':', $path);
// Deleting possible `/` at the beginning of the file path.
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method prepareRecipientsForMailMessage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$emails[$recipient['email']] = $recipient['name'];
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using count() function in for loops. Open
for ($i = 0; $i < count($title); $i++) {
$detailedTitle = $this->replaceCodeSections($title[$i]);
$pullRequest = null;
$detailedBody = preg_replace('/\n/', "\n> ", $body[$i]);
- Read upRead up
- Exclude checks
CountInLoopExpression
Since: 2.7.0
Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.
Example
class Foo {
public function bar()
{
$array = array();
for ($i = 0; count($array); $i++) {
// ...
}
}
}
Source https://phpmd.org/rules/design.html#countinloopexpression
registerEntityNotificationControllers accesses the super-global variable $GLOBALS. Open
public function registerEntityNotificationControllers()
{
$controllers = [
'Backend\\Manager\\Notification\\ShowEntityEmail' => [
'show',
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
injectHookInGlobalArray accesses the super-global variable $GLOBALS. Open
protected function injectHookInGlobalArray($closure)
{
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'] = ArrayUtility::setValueByPath(
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'],
$this->getFullPath(),
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
doProcess accesses the super-global variable $GLOBALS. Open
protected function doProcess(string $tableName)
{
$flexFormDs = [
'default' => 'FILE:EXT:notiz/Configuration/FlexForm/Event/Default.xml',
];
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
injectHookInGlobalArray accesses the super-global variable $GLOBALS. Open
protected function injectHookInGlobalArray($closure)
{
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'] = ArrayUtility::setValueByPath(
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'],
$this->getFullPath(),
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
registerInternalCache accesses the super-global variable $GLOBALS. Open
protected function registerInternalCache()
{
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][NotizConstants::CACHE_ID])) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][NotizConstants::CACHE_ID] = [
'backend' => FileBackend::class,
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
resetTypeConvertersArray accesses the super-global variable $GLOBALS. Open
protected function resetTypeConvertersArray()
{
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'] = array_unique($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters']);
}
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}