Call to method __construct
from undeclared class \Nette\PhpGenerator\PhpLiteral
Open
$configFile->set('SMARTY_ERROR_REPORTING', new \Nette\PhpGenerator\PhpLiteral('E_ALL'));
- Exclude checks
Call to method __construct
from undeclared class \Nette\PhpGenerator\PhpLiteral
Open
$configFile->set('EXCEPTION_ERROR_LEVEL', new \Nette\PhpGenerator\PhpLiteral('E_ALL'));
- Exclude checks
Call to method __construct
from undeclared class \Nette\PhpGenerator\PhpLiteral
Open
\App\Config::set('module', 'OSSMail', 'root_directory', new \Nette\PhpGenerator\PhpLiteral('ROOT_DIRECTORY . DIRECTORY_SEPARATOR'));
- Exclude checks
Define a constant instead of duplicating this literal "component" 3 times. Open
\App\Config::set('component', 'Mail', 'MAILER_REQUIRED_ACCEPTATION_BEFORE_SENDING', true);
- 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.
Remove this commented out code. Open
// $configFile->set('MISSING_LIBRARY_DEV_MODE', true);
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Define a constant instead of duplicating this literal "module" 3 times. Open
\App\Config::set('module', 'OSSMail', 'root_directory', new \Nette\PhpGenerator\PhpLiteral('ROOT_DIRECTORY . DIRECTORY_SEPARATOR'));
- 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.
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('db_username', 'yetiforce');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('default_timezone', 'Europe/Warsaw');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('layoutInLoginView', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('LOG_LEVELS', ['error', 'warning']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('MINIMIZE_JS', false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Config::set('module', 'OSSMail', 'root_directory', new \Nette\PhpGenerator\PhpLiteral('ROOT_DIRECTORY . DIRECTORY_SEPARATOR'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!is_dir($dirPath)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$componentsData = require_once "$path";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('apiShowExceptionBacktrace', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('SMARTY_ERROR_REPORTING', new \Nette\PhpGenerator\PhpLiteral('E_ALL'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('enableCardDAV', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('db_type', 'mysql');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('DISPLAY_EXCEPTION_LOGS', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('askAdminAboutVisitPurpose', false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
file_put_contents($path, $content);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
require_once 'include/main/WebUI.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile = new \App\ConfigFile('db');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile = new \App\ConfigFile('developer');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('askSuperUserAboutVisitPurpose', false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$skip = ['db', 'main', 'debug', 'developer', 'security', 'module', 'component'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
file_put_contents($path, $content);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('db_password', 'Q4WK2yRUpliyjMRivDJE');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile = new \App\ConfigFile('main');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile = new \App\ConfigFile('debug');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('LOG_TRACE_LEVEL', 9);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('enableCalDAV', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('apiLogAllRequests', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->create();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('LANGUAGES_UPDATE_DEV_MODE', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('SHOW_RECORDS_COUNT', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$path = \ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'config' . \DIRECTORY_SEPARATOR . 'Components' . \DIRECTORY_SEPARATOR . 'ConfigTemplates.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('enabledServices', ['dav', 'webservice']);
- Exclude checks
Line exceeds 120 characters; contains 147 characters Open
$path = \ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'config' . \DIRECTORY_SEPARATOR . 'Components' . \DIRECTORY_SEPARATOR . 'ConfigTemplates.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('cookieForceHttpOnly', false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['; Pool Definitions ;', ''],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('systemMode', 'test');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('apiShowExceptionMessages', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('apiShowExceptionReasonPhrase', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('davDebugExceptions', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->create();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile = new \App\ConfigFile('relation');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (array_diff(\App\ConfigFile::TYPES, $skip) as $type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('loginSessionRegenerate', false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
["; Pool Definitions ;\nlog_level = warning\nerror_log = /var/log/fpm-php.www.log\n"],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
file_get_contents($path)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('db_server', 'localhost');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('db_port', 3306);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('EXCEPTION_ERROR_LEVEL', new \Nette\PhpGenerator\PhpLiteral('E_ALL'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
(new \App\ConfigFile($type))->create();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
(new \App\ConfigFile('module', $moduleName))->create();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('langInLoginView', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->create();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dirPath = \ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'config' . \DIRECTORY_SEPARATOR . 'Modules';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($componentsData as $component => $data) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($item->isDir() && !\in_array($item->getBasename(), ['.', '..'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('LOG_TO_FILE', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('DISPLAY_EXCEPTION_BACKTRACE', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('DEBUG_CRON', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->create();
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
\App\Config::set('module', 'OSSMail', 'root_directory', new \Nette\PhpGenerator\PhpLiteral('ROOT_DIRECTORY . DIRECTORY_SEPARATOR'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
chdir(__DIR__ . '/../../');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('db_name', 'yetiforce');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('CHANGE_GENERATEDTYPE', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('CHANGE_RELATIONS', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// $configFile->set('MISSING_LIBRARY_DEV_MODE', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('RESET_LOGIN_PASSWORD', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->create();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('site_URL', 'http://localhost/');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content = str_replace('password = ', 'password = ' . getenv('DB_ROOT_PASS'), file_get_contents($path));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('default_language', 'en-US');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('EXCEPTION_ERROR_TO_SHOW', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content = str_replace(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('EXCEPTION_ERROR_TO_FILE', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('CHANGE_VISIBILITY', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('davDebugPlugin', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile = new \App\ConfigFile('api');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('PERMITTED_BY_PRIVATE_FIELD', false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile = new \App\ConfigFile('security');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->create();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Config::set('component', 'Mail', 'MAILER_REQUIRED_ACCEPTATION_BEFORE_SENDING', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ((new \DirectoryIterator('modules/')) as $item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
mkdir($dirPath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->create();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('MINIMIZE_CSS', false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$configFile->set('updaterDevMode', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $item->getBasename();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$filePath = 'modules' . \DIRECTORY_SEPARATOR . $moduleName . \DIRECTORY_SEPARATOR . 'ConfigTemplate.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (file_exists($filePath)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
(new \App\ConfigFile('component', $component))->create();
- Exclude checks