Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php
/**
* All information in order to connect to database are going through here.
*
* Be careful if you are changing data's in this file.
- 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 742.
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
Tabs must be used to indent lines; spaces are not allowed Open
exit();
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
die("ImpressCMS path check: this file cannot be requested directly");
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
exit("ImpressCMS path check: Script is not inside XOOPS_ROOT_PATH and cannot run.");
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
if (isset( $_REQUEST[$bad_global] )) {
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
header( 'Location: '.XOOPS_URL.'/' );
- Exclude checks
Space found after opening bracket of FOREACH loop Open
foreach ( array('GLOBALS', '_SESSION', 'HTTP_SESSION_VARS', '_GET', 'HTTP_GET_VARS', '_POST', 'HTTP_POST_VARS', '_COOKIE', 'HTTP_COOKIE_VARS', '_REQUEST', '_SERVER', 'HTTP_SERVER_VARS', '_ENV', 'HTTP_ENV_VARS', '_FILES', 'HTTP_POST_FILES', 'xoopsDB', 'xoopsUser', 'xoopsUserId', 'xoopsUserGroups', 'xoopsUserIsAdmin', 'icmsConfig', 'xoopsOption', 'xoopsModule', 'xoopsModuleConfig', 'xoopsRequestUri') as $bad_global) {
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
define('XOOPS_DB_CHARSET', '');
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
}
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
if (defined('XOOPS_DB_CHARSET')) die();
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
foreach ( array('GLOBALS', '_SESSION', 'HTTP_SESSION_VARS', '_GET', 'HTTP_GET_VARS', '_POST', 'HTTP_POST_VARS', '_COOKIE', 'HTTP_COOKIE_VARS', '_REQUEST', '_SERVER', 'HTTP_SERVER_VARS', '_ENV', 'HTTP_ENV_VARS', '_FILES', 'HTTP_POST_FILES', 'xoopsDB', 'xoopsUser', 'xoopsUserId', 'xoopsUserGroups', 'xoopsUserIsAdmin', 'icmsConfig', 'xoopsOption', 'xoopsModule', 'xoopsModuleConfig', 'xoopsRequestUri') as $bad_global) {
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
// Set the database charset if applicable
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
}
- Exclude checks
Inline control structures are not allowed Open
if (defined('XOOPS_DB_CHARSET')) die();
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
header( 'Location: '.XOOPS_URL.'/' );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
define( 'ICMS_TRUST_PATH', XOOPS_TRUST_PATH );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
define( 'ICMS_URL', XOOPS_URL );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
header( 'Location: '.XOOPS_URL.'/' );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
$xoopsScriptPath = str_replace( strpos( $xoopsScriptPath, '\\\\', 2 ) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $xoopsScriptPath);
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
define( 'ICMS_TRUST_PATH', XOOPS_TRUST_PATH );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
$xoopsScriptPath = str_replace( strpos( $xoopsScriptPath, '\\\\', 2 ) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $xoopsScriptPath);
- Exclude checks
Space after opening parenthesis of function call prohibited Open
define( 'ICMS_ROOT_PATH', XOOPS_ROOT_PATH );
- Exclude checks
Expected 0 spaces after opening bracket; 1 found Open
foreach ( array('GLOBALS', '_SESSION', 'HTTP_SESSION_VARS', '_GET', 'HTTP_GET_VARS', '_POST', 'HTTP_POST_VARS', '_COOKIE', 'HTTP_COOKIE_VARS', '_REQUEST', '_SERVER', 'HTTP_SERVER_VARS', '_ENV', 'HTTP_ENV_VARS', '_FILES', 'HTTP_POST_FILES', 'xoopsDB', 'xoopsUser', 'xoopsUserId', 'xoopsUserGroups', 'xoopsUserIsAdmin', 'icmsConfig', 'xoopsOption', 'xoopsModule', 'xoopsModuleConfig', 'xoopsRequestUri') as $bad_global) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
define( 'ICMS_ROOT_PATH', XOOPS_ROOT_PATH );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
if (strcasecmp( substr($xoopsScriptPath, 0, strlen(XOOPS_ROOT_PATH)), str_replace( DIRECTORY_SEPARATOR, '/', XOOPS_ROOT_PATH))) {
- Exclude checks
No space found after comma in function call Open
define("XOOPS_MAINFILE_INCLUDED",1);
- Exclude checks
Space after opening parenthesis of function call prohibited Open
if (isset( $_REQUEST[$bad_global] )) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
$xoopsScriptPath = str_replace( strpos( $xoopsScriptPath, '\\\\', 2 ) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $xoopsScriptPath);
- Exclude checks
Space after opening parenthesis of function call prohibited Open
if (strcasecmp( substr($xoopsScriptPath, 0, strlen(XOOPS_ROOT_PATH)), str_replace( DIRECTORY_SEPARATOR, '/', XOOPS_ROOT_PATH))) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
if (isset( $_REQUEST[$bad_global] )) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
define( 'ICMS_URL', XOOPS_URL );
- Exclude checks
Expected 1 newline at end of file; 0 found Open
}
- Exclude checks
Unexpected spaces found. Open
// Set the database charset if applicable
- Exclude checks
Unexpected spaces found. Open
exit();
- Exclude checks
Unexpected trailing spaces found. Open
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
die("ImpressCMS path check: this file cannot be requested directly");
- Exclude checks
Unexpected spaces found. Open
foreach ( array('GLOBALS', '_SESSION', 'HTTP_SESSION_VARS', '_GET', 'HTTP_GET_VARS', '_POST', 'HTTP_POST_VARS', '_COOKIE', 'HTTP_COOKIE_VARS', '_REQUEST', '_SERVER', 'HTTP_SERVER_VARS', '_ENV', 'HTTP_ENV_VARS', '_FILES', 'HTTP_POST_FILES', 'xoopsDB', 'xoopsUser', 'xoopsUserId', 'xoopsUserGroups', 'xoopsUserIsAdmin', 'icmsConfig', 'xoopsOption', 'xoopsModule', 'xoopsModuleConfig', 'xoopsRequestUri') as $bad_global) {
- Exclude checks
Unexpected trailing spaces found. Open
- Exclude checks
Unexpected spaces found. Open
if (defined('XOOPS_DB_CHARSET')) die();
- Exclude checks
Unexpected spaces found. Open
header( 'Location: '.XOOPS_URL.'/' );
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
exit("ImpressCMS path check: Script is not inside XOOPS_ROOT_PATH and cannot run.");
- Exclude checks
Unexpected spaces found. Open
if (isset( $_REQUEST[$bad_global] )) {
- Exclude checks
Unexpected spaces found. Open
- Exclude checks
Unexpected spaces found. Open
define('XOOPS_DB_CHARSET', '');
- Exclude checks