apply_auth_db accesses the super-global variable $GLOBALS. Open
function apply_auth_db() {
$db = $GLOBALS['xoopsDB'];
// Insert config values
$table = $db->prefix( 'config' );
- 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
query accesses the super-global variable $GLOBALS. Open
function query( $sql) {
$db = $GLOBALS['xoopsDB'];
if (! ( $ret = $db->queryF( $sql ) )) {
echo $db->error();
}
- 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
check_auth_db accesses the super-global variable $GLOBALS. Open
function check_auth_db() {
$db = $GLOBALS['xoopsDB'];
$value = getDbValue( $db, 'config', 'conf_id',
"`conf_name` = 'ldap_use_TLS' AND `conf_catid` = " . XOOPS_CONF_AUTH
);
- 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
Avoid assigning values to variables in if clauses and the like (line '37', column '11'). Open
function query( $sql) {
$db = $GLOBALS['xoopsDB'];
if (! ( $ret = $db->queryF( $sql ) )) {
echo $db->error();
}
- 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 unused local variables such as '$ret'. Open
if (! ( $ret = $db->queryF( $sql ) )) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Reference to undeclared constant \XOOPS_CONF_AUTH
Open
"`conf_name` = 'ldap_use_TLS' AND `conf_catid` = " . XOOPS_CONF_AUTH
- Exclude checks
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php
class upgrade_2016 {
var $usedFiles = array( );
- 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 253.
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
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class upgrade_2016 {
- Exclude checks
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = $GLOBALS['xoopsDB'];
- 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
The class upgrade_2016 is not named in CamelCase. Open
class upgrade_2016 {
var $usedFiles = array( );
function isApplied() {
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = $GLOBALS['xoopsDB'];
- 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
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = $GLOBALS['xoopsDB'];
- 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
Visibility must be declared on method "isApplied" Open
function isApplied() {
- Exclude checks
Space found after opening bracket of FOREACH loop Open
foreach ( $data as $name => $values) {
- Exclude checks
The var keyword must not be used to declare a property Open
var $usedFiles = array( );
- Exclude checks
Visibility must be declared on method "query" Open
function query( $sql) {
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
'ldap_use_TLS' => "'_MD_AM_LDAP_USETLS', '0', '_MD_AM_LDAP_USETLS_DESC', 'yesno', 'int', 21",
- Exclude checks
Expected 0 spaces between opening bracket and argument "$sql"; 1 found Open
function query( $sql) {
- Exclude checks
Visibility must be declared on method "check_file_patch" Open
function check_file_patch() {
- Exclude checks
Visibility must be declared on method "apply_auth_db" Open
function apply_auth_db() {
- Exclude checks
Visibility must be declared on property "$usedFiles" Open
var $usedFiles = array( );
- Exclude checks
Visibility must be declared on method "apply" Open
function apply() {
- Exclude checks
Visibility must be declared on method "check_auth_db" Open
function check_auth_db() {
- Exclude checks
Method name "upgrade_2016::apply_auth_db" is not in camel caps format Open
function apply_auth_db() {
- Exclude checks
Method name "upgrade_2016::check_auth_db" is not in camel caps format Open
function check_auth_db() {
- Exclude checks
Method name "upgrade_2016::check_file_patch" is not in camel caps format Open
function check_file_patch() {
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$value = getDbValue( $db, 'config', 'conf_id',
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$value = getDbValue( $db, 'config', 'conf_id',
- Exclude checks
Class name "upgrade_2016" is not in camel caps format Open
class upgrade_2016 {
- Exclude checks
Expected 1 newline at end of file; 0 found Open
?>
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
if (!getDbValue( $db, 'config', 'conf_id', "`conf_modid`=0 AND `conf_catid`=7 AND `conf_name`='$name'" )) {
- Exclude checks
Opening parenthesis of a multi-line function call must be the last content on the line Open
$value = getDbValue( $db, 'config', 'conf_id',
- Exclude checks
Space after opening parenthesis of function call prohibited Open
$table = $db->prefix( 'config' );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
$table = $db->prefix( 'config' );
- Exclude checks
A closing tag is not permitted at the end of a PHP file Open
?>
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
if (! ( $ret = $db->queryF( $sql ) )) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
if (!getDbValue( $db, 'config', 'conf_id', "`conf_modid`=0 AND `conf_catid`=7 AND `conf_name`='$name'" )) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
if (! ( $ret = $db->queryF( $sql ) )) {
- Exclude checks
Expected 0 spaces after opening bracket; 1 found Open
foreach ( $data as $name => $values) {
- Exclude checks
The method apply_auth_db is not named in camelCase. Open
function apply_auth_db() {
$db = $GLOBALS['xoopsDB'];
// Insert config values
$table = $db->prefix( 'config' );
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method check_file_patch is not named in camelCase. Open
function check_file_patch() {
/* $path = XOOPS_ROOT_PATH . '/class/auth';
$lines = file( "$path/auth_provisionning.php");
foreach ( $lines as $line) {
if (strpos( $line, "ldap_provisionning_upd" ) !== false) {
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method check_auth_db is not named in camelCase. Open
function check_auth_db() {
$db = $GLOBALS['xoopsDB'];
$value = getDbValue( $db, 'config', 'conf_id',
"`conf_name` = 'ldap_use_TLS' AND `conf_catid` = " . XOOPS_CONF_AUTH
);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
Unexpected spaces found. Open
'ldap_use_TLS' => "'_MD_AM_LDAP_USETLS', '0', '_MD_AM_LDAP_USETLS_DESC', 'yesno', 'int', 21",
- Exclude checks