Showing 289 of 289 total issues
Avoid using static access to class 'CodeColorerOptions' in method 'performHighlightCodeBlock'. Open
$options = CodeColorerOptions::parseOptions($opts, $suffix);
- 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 'CodeColorerLoader' in method 'codecolorer_highlight'. Open
return CodeColorerLoader::highlight($code);
- 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 assigning values to variables in if clauses and the like (line '94', column '23'). Open
public static function parseOptions($opts, $suffix = '')
{
$opts = str_replace(array("\\\"", "\\\'"), array ("\"", "\'"), $opts);
preg_match_all('#([a-z_-]*?)\s*=\s*(["\'])(.*?)\2#i', $opts, $matches, PREG_SET_ORDER);
$options = array();
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid assigning values to variables in if clauses and the like (line '91', column '23'). Open
public static function parseOptions($opts, $suffix = '')
{
$opts = str_replace(array("\\\"", "\\\'"), array ("\"", "\'"), $opts);
preg_match_all('#([a-z_-]*?)\s*=\s*(["\'])(.*?)\2#i', $opts, $matches, PREG_SET_ORDER);
$options = array();
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class 'CodeColorer' in method 'callShowGeshiWarning'. Open
$codecolorer = &CodeColorer::getInstance();
- 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 'CodeColorer' in method 'callAfterHighlightCodeBlock'. Open
$codecolorer = &CodeColorer::getInstance();
- 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 'CodeColorer' in method 'callAfterProtectComment'. Open
$codecolorer = &CodeColorer::getInstance();
- 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
The method populateDefaultValues() has a Cyclomatic Complexity of 22. The configured cyclomatic complexity threshold is 10. Open
protected static function populateDefaultValues($options)
{
if (!$options) {
$options = array();
}
- 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 performHighlightGeshi() has a Cyclomatic Complexity of 18. The configured cyclomatic complexity threshold is 10. Open
private function performHighlightGeshi($content, $options)
{
/* Geshi configuration */
if (!$this->geshi) {
$this->geshi = new GeSHi();
- 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
Avoid using sizeof() function in for loops. Open
for ($i = 0; $i < sizeof($matches); $i++) {
$options[$matches[$i][1]] = $matches[$i][3];
}
- 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
disableNotifications accesses the super-global variable $_GET. Open
private function disableNotifications()
{
if (isset($_GET['disable']) && in_array($_GET['disable'], array('concurrent', 'language'))) {
update_option('codecolorer_' . $_GET['disable'] . '_notification', false);
}
- 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
disableNotifications accesses the super-global variable $_GET. Open
private function disableNotifications()
{
if (isset($_GET['disable']) && in_array($_GET['disable'], array('concurrent', 'language'))) {
update_option('codecolorer_' . $_GET['disable'] . '_notification', false);
}
- 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
disableNotifications accesses the super-global variable $_GET. Open
private function disableNotifications()
{
if (isset($_GET['disable']) && in_array($_GET['disable'], array('concurrent', 'language'))) {
update_option('codecolorer_' . $_GET['disable'] . '_notification', false);
}
- 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
The method parseOptions() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public static function parseOptions($opts, $suffix = '')
{
$opts = str_replace(array("\\\"", "\\\'"), array ("\"", "\'"), $opts);
preg_match_all('#([a-z_-]*?)\s*=\s*(["\'])(.*?)\2#i', $opts, $matches, PREG_SET_ORDER);
$options = array();
- 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 addContainer() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
private function addContainer($html, $options, $numLines)
{
$customCSSClass = empty($options['class']) ? '' : ' ' . $options['class'];
if ($options['inline']) {
$theme = empty($options['inline_theme']) ? 'default' : $options['inline_theme'];
- 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
Line exceeds 120 characters; contains 140 characters Open
<th scope="row"><label for="codecolorer_lines_to_scroll"><?php _e('Lines to scroll', 'codecolorer') ?>:</label></th>
- Exclude checks
Line exceeds 120 characters; contains 200 characters Open
<input name="codecolorer_tab_size" type="number" class="small-text" size="60" id="codecolorer_tab_size" value="<?php echo esc_html(get_option('codecolorer_tab_size')) ?>"/>
- Exclude checks
Line exceeds 120 characters; contains 134 characters Open
<th scope="row"><label for="codecolorer_inline_theme"><?php _e('Inline Theme', 'codecolorer') ?>:</label></th>
- Exclude checks
Line exceeds 120 characters; contains 139 characters Open
<input type="submit" class="button-primary" name="Submit" value="<?php _e('Save Options', 'codecolorer') ?> »" />
- Exclude checks
Line exceeds 120 characters; contains 147 characters Open
<p class="description"><?php _e('Default code block width in RSS. See Width option description.', 'codecolorer') ?></p>
- Exclude checks