getSetLimitAndOffset accesses the super-global variable $_GET. Open
public function getSetLimitAndOffset(
$defaultLimit = 1000,
$defaultOffset = 0,
$maxLimit = 5000,
$minLimit = 100
- 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
getSetLimitAndOffset accesses the super-global variable $_GET. Open
public function getSetLimitAndOffset(
$defaultLimit = 1000,
$defaultOffset = 0,
$maxLimit = 5000,
$minLimit = 100
- 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
getSetLimitAndOffset accesses the super-global variable $_GET. Open
public function getSetLimitAndOffset(
$defaultLimit = 1000,
$defaultOffset = 0,
$maxLimit = 5000,
$minLimit = 100
- 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
getSetLimitAndOffset accesses the super-global variable $_GET. Open
public function getSetLimitAndOffset(
$defaultLimit = 1000,
$defaultOffset = 0,
$maxLimit = 5000,
$minLimit = 100
- 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
getSetLimitAndOffset accesses the super-global variable $_GET. Open
public function getSetLimitAndOffset(
$defaultLimit = 1000,
$defaultOffset = 0,
$maxLimit = 5000,
$minLimit = 100
- 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
getSetLimitAndOffset accesses the super-global variable $_GET. Open
public function getSetLimitAndOffset(
$defaultLimit = 1000,
$defaultOffset = 0,
$maxLimit = 5000,
$minLimit = 100
- 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
File SqliteDatabase.php
has 323 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php // Attogram Framework - Database Module - SqliteDatabase class v0.3.20
namespace Attogram;
/**
The class SqliteDatabase has an overall complexity of 78 which is very high. The configured complexity threshold is 50. Open
class SqliteDatabase implements AttogramDatabaseInterface
{
public $databaseName; // (string) path/filename of the SQLite database file
public $modulesDirectory; // (string) The Attogram Modules directory
- Exclude checks
Method tabler
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function tabler(
$table,
$tableId,
$nameSingular,
$namePlural, // TODO - remove unused
Function tabler
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function tabler(
$table,
$tableId,
$nameSingular,
$namePlural, // TODO - remove unused
- 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 pager
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function pager($count, $limit, $offset, $preQS = '')
{
if ($limit > $count) {
$limit = $count;
}
- 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 pager
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function pager($count, $limit, $offset, $preQS = '')
{
if ($limit > $count) {
$limit = $count;
}
Function loadTableDefinitions
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function loadTableDefinitions()
{
if (isset($this->tables) && is_array($this->tables)) {
return true;
}
- 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, // TODO - remove unused
$publicLink,
Method query
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function query($sql, array $bind = array())
{
$this->log->debug('QUERY: backtrace='.(($btr = debug_backtrace())
? $btr[1]['function'] : '?' ).' sql='.$sql);
if ($bind) {
Function queryPrepare
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function queryPrepare($sql)
{
$statement = $this->database->prepare($sql);
if ($statement) {
return $statement;
- 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 query
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function query($sql, array $bind = array())
{
$this->log->debug('QUERY: backtrace='.(($btr = debug_backtrace())
? $btr[1]['function'] : '?' ).' sql='.$sql);
if ($bind) {
- 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 initDB
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function initDB()
{
if (is_object($this->database) && get_class($this->database) == 'PDO') {
return true; // if PDO database object already set
}
- 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 getSetLimitAndOffset
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getSetLimitAndOffset(
$defaultLimit = 1000,
$defaultOffset = 0,
$maxLimit = 5000,
$minLimit = 100
- 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 pager() has an NPath complexity of 448. The configured NPath complexity threshold is 200. Open
public function pager($count, $limit, $offset, $preQS = '')
{
if ($limit > $count) {
$limit = $count;
}
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method tabler has 10 parameters. Consider reducing the number of parameters to less than 10. Open
public function tabler(
$table,
$tableId,
$nameSingular,
$namePlural, // TODO - remove unused
- Exclude checks
The method tabler() has an NPath complexity of 1920. The configured NPath complexity threshold is 200. Open
public function tabler(
$table,
$tableId,
$nameSingular,
$namePlural, // TODO - remove unused
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method tabler() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10. Open
public function tabler(
$table,
$tableId,
$nameSingular,
$namePlural, // TODO - remove unused
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method pager() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public function pager($count, $limit, $offset, $preQS = '')
{
if ($limit > $count) {
$limit = $count;
}
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Remove error control operator '@' on line 89. Open
public function query($sql, array $bind = array())
{
$this->log->debug('QUERY: backtrace='.(($btr = debug_backtrace())
? $btr[1]['function'] : '?' ).' sql='.$sql);
if ($bind) {
- 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
Remove error control operator '@' on line 80. Open
public function query($sql, array $bind = array())
{
$this->log->debug('QUERY: backtrace='.(($btr = debug_backtrace())
? $btr[1]['function'] : '?' ).' sql='.$sql);
if ($bind) {
- 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
Remove error control operator '@' on line 128. Open
public function queryb($sql, array $bind = array())
{
$this->log->debug('QUERYB: backtrace='.(($btr = debug_backtrace())
? $btr[1]['function'] : '?').' sql='.$sql);
if ($bind) {
- 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
Missing class import via use statement (line '52', column '35'). Open
$this->database = new \PDO('sqlite:'. $this->databaseName);
- 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 120. Open
public function queryb($sql, array $bind = array())
{
$this->log->debug('QUERYB: backtrace='.(($btr = debug_backtrace())
? $btr[1]['function'] : '?').' sql='.$sql);
if ($bind) {
- 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
Remove error control operator '@' on line 147. Open
public function queryPrepare($sql)
{
$statement = $this->database->prepare($sql);
if ($statement) {
return $statement;
- 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 using static access to class '\PDO' in method 'initDB'. Open
if (!in_array('sqlite', \PDO::getAvailableDrivers())) {
- 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 'Attogram\Attogram' in method 'loadTableDefinitions'. Open
foreach (array_diff(scandir($d), Attogram::getSkipFiles()) as $f) {
- 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 'Attogram\Attogram' in method 'loadTableDefinitions'. Open
$dirs = Attogram::getAllSubdirectories($this->modulesDirectory, 'tables');
- 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 unused parameters such as '$namePlural'. Open
$namePlural, // TODO - remove unused
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$adminLink'. Open
$adminLink, // TODO - remove unused
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Class implements undeclared interface \Attogram\AttogramDatabaseInterface
Open
class SqliteDatabase implements AttogramDatabaseInterface
- Exclude checks
Reference to undeclared property \Attogram\SqliteDatabase->tables
(Did you mean $table) Open
if (!$this->queryb($this->tables[$table])) {
- Exclude checks
Saw an @param annotation for countSql,
but it was not found in the param list of function tabler(string $table, string $tableId, string $nameSingular, string $namePlural, string $publicLink, array $col, string $sql, string $adminLink, bool $showEdit, int $perPage) : string
Open
* @param string $countSql SQL query to get total number of items in table
- Exclude checks
Reference to undeclared property \Attogram\SqliteDatabase->tables
Open
$this->tables = array();
- Exclude checks
Method \Attogram\SqliteDatabase::tabler
is declared to return string
but has no return value Open
public function tabler(
- Exclude checks
TODO found Open
$namePlural, // TODO - remove unused
- Exclude checks
TODO found Open
// TODO dev: Warning: PDOStatement::bindParam(): SQLSTATE[HY093]: Invalid parameter number: Columns/Parameters are 1-based
- Exclude checks
TODO found Open
$adminLink, // TODO - remove unused
- Exclude checks
Call to method getSkipFiles
from undeclared class \Attogram\Attogram
Open
foreach (array_diff(scandir($d), Attogram::getSkipFiles()) as $f) {
- Exclude checks
Reference to undeclared property \Attogram\SqliteDatabase->tables
Open
$this->tables[$tableName] = file_get_contents($file);
- Exclude checks
TODO found Open
print '<td>'.htmlentities($row[$column['key']]).'</td>'; // TODO better filter, attogram webDisplay?
- Exclude checks
Expected @param annotation for publicLink
to be before the @param annotation for col
Open
* @param array $col Column Display Info - array of array('class'=>'...', 'title'=>'...', 'key'=>'...')
- Exclude checks
Reference to undeclared property \Attogram\SqliteDatabase->tables
Open
if (isset($this->tables) && is_array($this->tables)) {
- Exclude checks
Reference to undeclared property \Attogram\SqliteDatabase->tables
(Did you mean $table) Open
if (!isset($this->tables[$table])) {
- Exclude checks
Call to method getAllSubdirectories
from undeclared class \Attogram\Attogram
Open
$dirs = Attogram::getAllSubdirectories($this->modulesDirectory, 'tables');
- Exclude checks
Multi-line function declarations must define one parameter per line Open
$adminLink, // TODO - remove unused
- Exclude checks
The closing brace for the class must go on the next line after the body Open
} // END of class SqliteDatabase
- Exclude checks
Multi-line function declarations must define one parameter per line Open
$namePlural, // TODO - remove unused
- Exclude checks
Line exceeds 120 characters; contains 134 characters Open
// TODO dev: Warning: PDOStatement::bindParam(): SQLSTATE[HY093]: Invalid parameter number: Columns/Parameters are 1-based
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
* @param string $preQS (optional) URL Query String to prepend to pagination links, pairs of name=value&name=value&...
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
$result = '<p class="small">Showing # '."<strong>$startCount</strong> - <strong>$endCount</strong> of <code>$count</code> results</p>";
- Exclude checks