Showing 308 of 308 total issues
Function virtualWebDirectory
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function virtualWebDirectory()
{
if (!preg_match('/^\/'.'web'.'\//', $this->request->getPathInfo())) {
return; // not a virtual web directory request
}
- 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 route
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function route()
{
if (is_dir($this->uri[0])) { // requesting a directory?
$this->log->error('ROUTE: 403 Action Forbidden');
$this->error404('No spelunking allowed');
- 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
Method virtualWebDirectory
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function virtualWebDirectory()
{
if (!preg_match('/^\/'.'web'.'\//', $this->request->getPathInfo())) {
return; // not a virtual web directory request
}
The class Attogram has 20 fields. Consider redesigning Attogram to keep the number of fields under 15. Open
class Attogram
{
const ATTOGRAM_VERSION = '0.8.2';
public $startTime; // (float) microsecond time of awakening
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
Method meditate
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function meditate()
{
// Set default configuration
$this->config = array();
$this->config['attogramDirectory'] = '..'.DIRECTORY_SEPARATOR;
Method testNullDatabase
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function testNullDatabase()
{
$nullDatabase = new \Attogram\NullDatabase;
$this->assertFalse(
$nullDatabase->initDB(),
Method tabler
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
$table,
$tableId,
$nameSingular,
$namePlural,
$publicLink,
Function getActionables
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function getActionables($dir)
{
$result = array();
if (!is_readable($dir)) {
$this->log->error('GET_ACTIONABLES: directory not readable: '.$dir);
- 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
Method tabler
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
$table,
$tableId,
$nameSingular,
$namePlural,
$publicLink,
Function tranquility
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function tranquility()
{
// Speed things up! gz compession
//if (ob_start('ob_gzhandler')) {
// $this->debug('tranquility: ob_gzhandler active');
- 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 class Attogram has 51 public methods and attributes. Consider reducing the number of public items to less than 45. Open
class Attogram
{
const ATTOGRAM_VERSION = '0.8.2';
public $startTime; // (float) microsecond time of awakening
- Read upRead up
- Exclude checks
ExcessivePublicCount
Since: 0.1
A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.
Example
public class Foo {
public $value;
public $something;
public $var;
// [... more more public attributes ...]
public function doWork() {}
public function doMoreWork() {}
public function doWorkAgain() {}
// [... more more public methods ...]
}
Source https://phpmd.org/rules/codesize.html#excessivepubliccount
Method endSlash
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function endSlash()
{
if (!is_array($this->noEndSlash)) {
return;
}
Method apacheConfExamine
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function apacheConfExamine($conf)
{
$thisDir = '';
$allowOverride = array();
$file = new SplFileObject($conf);
Consider simplifying this complex logical expression. Open
if ((isset($this->config['debug']) // debug is true...
&& is_bool($this->config['debug'])
&& $this->config['debug'])
||
($request->query->has('debug') // admin debug url override ?debug
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class AttogramTest extends PHPUnit\Framework\TestCase
- Exclude checks
Function getAllSubdirectories
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function getAllSubdirectories($dir, $name)
{
if (!isset($dir) || !$dir || !is_string($dir) || !is_readable($dir)) {
return array();
}
- 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
Avoid variables with short names like $md. Configured minimum length is 3. Open
$md = $dir.DIRECTORY_SEPARATOR.$d;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 14 and the first side effect is on line 8. Open
<?php
- Exclude checks
Avoid variables with short names like $ff. Configured minimum length is 3. Open
$ff = $dir.DIRECTORY_SEPARATOR.$f;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 10 and the first side effect is on line 6. Open
<?php
- Exclude checks