Showing 308 of 308 total issues
Function setModuleTemplates
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function setModuleTemplates()
{
$dirs = $this->getAllSubdirectories($this->modulesDirectory, 'templates');
if (!$dirs) {
//$this->log->debug('setModuleTemplates: no module templates found. Using defaults.');
- 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
Consider simplifying this complex logical expression. Open
if (!$file || !$type || $type == '' || !is_string($type) || !is_string($file) || !is_readable($file)) {
return false;
}
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
\Psr\Log\LoggerInterface $log,
\Psr\Log\LoggerInterface $event,
\Attogram\AttogramDatabaseInterface $database,
\Symfony\Component\HttpFoundation\Request $request,
array $config = array()
Method guruMeditationErrorHandler
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$level,
$message,
$file = '',
$line = '',
$context = array()
Similar blocks of code found in 3 locations. Consider refactoring. Open
if (preg_match('/ErrorDocument\s+404/', $val)) {
++$count['ErrorDocument 404'];
if (preg_match('/ErrorDocument\s+404\s+(.*)\s+$/', $val, $match)) {
$found['ErrorDocument 404'] = trim($match[1]);
if (trim($match[1]) == $goodUri) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 92.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
if (preg_match('/FallbackResource/', $val)) {
++$count['FallbackResource'];
if (preg_match('/FallbackResource\s+(.*)\s+$/', $val, $match)) {
$found['FallbackResource'] = trim($match[1]);
if (trim($match[1]) == $goodUri) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 92.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
if (preg_match('/ErrorDocument\s+403/', $val)) {
++$count['ErrorDocument 403'];
if (preg_match('/ErrorDocument\s+403\s+(.*)\s+$/', $val, $match)) {
$found['ErrorDocument 403'] = trim($match[1]);
if (trim($match[1]) == $goodUri) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 92.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function defaultHomepage
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function defaultHomepage()
{
$this->log->error('using defaultHomepage');
$this->pageHeader('Home');
echo '<div class="container">'
- 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 guruMeditationErrorHandler
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function guruMeditationErrorHandler(
$level,
$message,
$file = '',
$line = '',
- 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 checkIndex
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function checkIndex()
{
$indexFile = './index.php';
file_exists($indexFile) ? $fileexists = 'pass' : $fileexists = 'fail';
echo '<pre class="'.$fileexists.'">'.$this->{$fileexists}.' 1.0 - <strong>'.$indexFile.'</strong> exists</pre>';
- 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 closing brace must go on the next line following the body; found 1 blank lines before brace Open
} // end function __construct()
- Exclude checks
Function includeAllPhpFilesInDirectory
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function includeAllPhpFilesInDirectory($dir)
{
$included = array();
if (!is_readable($dir)) {
return $included;
- 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 closing brace must go on the next line following the body; found 1 blank lines before brace Open
} // end function tranquility()
- Exclude checks
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return false;
Remove error control operator '@' on line 123. Open
public function awaken()
{
// The Site Administrator IP addresses
$this->remember(
'admins',
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return;
Missing class import via use statement (line '448', column '23'). Open
$parser = new \ParsedownExtra();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Remove error control operator '@' on line 592. Open
public function isAdmin()
{
if (isset($this->isAdmin) && is_bool($this->isAdmin)) {
return $this->isAdmin;
}
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}