Method icmsFormField
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function icmsFormField( $name, $value, $label, $maxlength, $help = '' )
Reference to undeclared constant \_SUBMIT
Open
<button type="submit"><?php echo _SUBMIT; ?></button>
- Exclude checks
Similar blocks of code found in 3 locations. Consider refactoring. Open
function icmsFormField( $name, $value, $label, $maxlength, $help = '' )
{
$label = htmlspecialchars( $label );
$name = htmlspecialchars( $name, ENT_QUOTES );
$value = htmlspecialchars( $value, ENT_QUOTES );
- 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 140.
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
$field .= '<div class="xoform-help1">' . $help . "</div>\n";
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$maxlength = (int) $maxlength;
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$vars['TRUST_PATH'] = '';
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$field = "<label for='$name'>$label</label>\n";
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
<button type="submit"><?php echo _SUBMIT; ?></button>
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$value = htmlspecialchars( $value, ENT_QUOTES );
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$error = ERR_NO_TRUST_PATH;
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
return $field;
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
if ($help) {
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$error = ERR_WRONG_TRUST_PATH;
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
die( 'Bad installation: please add this folder to the ImpressCMS install you want to upgrade');
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$name = htmlspecialchars( $name, ENT_QUOTES );
- 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
$label = htmlspecialchars( $label );
- Exclude checks
Expected 0 spaces between argument "$help" and closing bracket; 1 found Open
function icmsFormField( $name, $value, $label, $maxlength, $help = '' )
- Exclude checks
Expected 0 spaces between opening bracket and argument "$name"; 1 found Open
function icmsFormField( $name, $value, $label, $maxlength, $help = '' )
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
<?php if (!empty( $error ) ) echo '<div class="x2-note error">' . $error . "</div>\n"; ?>
- Exclude checks
Opening brace should be on the same line as the declaration Open
{
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
return false;
- Exclude checks
PHP keywords must be lowercase; expected "or" but found "OR" Open
} elseif (substr( $vars, -1 ) == '/' OR substr( $vars, -1 ) == '\'') {
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$error = ERR_INVALID_TRUST_PATH;
- Exclude checks
Expected 1 space after comma in function call; 4 found Open
<?php echo icmsFormField( 'TRUST_PATH', $vars['TRUST_PATH'], TRUST_PATH_LABEL, 255, TRUST_PATH_HELP ); ?>
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$field .= "<input type='text' name='$name' id='$name' value='$value' />";
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
if (@empty( $vars['TRUST_PATH'] ) )
- Exclude checks
Inline control structures are not allowed Open
<?php if (!empty( $error ) ) echo '<div class="x2-note error">' . $error . "</div>\n"; ?>
- Exclude checks
Space after opening parenthesis of function call prohibited Open
if (!defined( 'ICMS_ROOT_PATH' )) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
return str_replace( "//", "/", str_replace( "\\", "/", substr( $vars, 0, -1 ) ) );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
} elseif (substr( $vars, -1 ) == '/' OR substr( $vars, -1 ) == '\'') {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
$label = htmlspecialchars( $label );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
} elseif (!is_dir( $vars['TRUST_PATH'] )) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
if (@empty( $vars['TRUST_PATH'] ) )
- Exclude checks
Expected 1 space after closing parenthesis; found 5 Open
if (@empty( $vars['TRUST_PATH'] ) )
- Exclude checks
Space after opening parenthesis of function call prohibited Open
} elseif (substr( $vars, -1 ) == '/' OR substr( $vars, -1 ) == '\'') {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
} elseif (substr( $vars, -1 ) == '/' OR substr( $vars, -1 ) == '\'') {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
$name = htmlspecialchars( $name, ENT_QUOTES );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
die( 'Bad installation: please add this folder to the ImpressCMS install you want to upgrade');
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
return str_replace( "//", "/", str_replace( "\\", "/", $vars ) );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
return str_replace( "//", "/", str_replace( "\\", "/", $vars ) );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
if (!isset( $vars['TRUST_PATH'] )) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
if (!isset( $vars['TRUST_PATH'] )) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
$value = htmlspecialchars( $value, ENT_QUOTES );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
if (@empty( $vars['TRUST_PATH'] ) )
- Exclude checks
Space after opening parenthesis of function call prohibited Open
return str_replace( "//", "/", str_replace( "\\", "/", substr( $vars, 0, -1 ) ) );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
<?php echo icmsFormField( 'TRUST_PATH', $vars['TRUST_PATH'], TRUST_PATH_LABEL, 255, TRUST_PATH_HELP ); ?>
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
$value = htmlspecialchars( $value, ENT_QUOTES );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
} elseif (substr( $vars, -1 ) == '/' OR substr( $vars, -1 ) == '\'') {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
<?php if (!empty( $error ) ) echo '<div class="x2-note error">' . $error . "</div>\n"; ?>
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
return str_replace( "//", "/", str_replace( "\\", "/", substr( $vars, 0, -1 ) ) );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
return str_replace( "//", "/", str_replace( "\\", "/", substr( $vars, 0, -1 ) ) );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
return str_replace( "//", "/", str_replace( "\\", "/", $vars ) );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
$name = htmlspecialchars( $name, ENT_QUOTES );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
} elseif (!is_dir( $vars['TRUST_PATH'] )) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
return str_replace( "//", "/", str_replace( "\\", "/", substr( $vars, 0, -1 ) ) );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
<?php echo icmsFormField( 'TRUST_PATH', $vars['TRUST_PATH'], TRUST_PATH_LABEL, 255, TRUST_PATH_HELP ); ?>
- Exclude checks
Space after opening parenthesis of function call prohibited Open
return str_replace( "//", "/", str_replace( "\\", "/", substr( $vars, 0, -1 ) ) );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
<?php if (!empty( $error ) ) echo '<div class="x2-note error">' . $error . "</div>\n"; ?>
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
if (!defined( 'ICMS_ROOT_PATH' )) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
$label = htmlspecialchars( $label );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
return str_replace( "//", "/", str_replace( "\\", "/", $vars ) );
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
$field .= '<div class="xoform-help1">' . $help . "</div>\n";
- Exclude checks
Unexpected spaces found. Open
$maxlength = (int) $maxlength;
- Exclude checks
Unexpected spaces found. Open
die( 'Bad installation: please add this folder to the ImpressCMS install you want to upgrade');
- Exclude checks
Unexpected spaces found. Open
<button type="submit"><?php echo _SUBMIT; ?></button>
- Exclude checks
Unexpected spaces found. Open
$field .= "<input type='text' name='$name' id='$name' value='$value' />";
- Exclude checks
Unexpected spaces found. Open
$value = htmlspecialchars( $value, ENT_QUOTES );
- Exclude checks
Unexpected spaces found. Open
if ($help) {
- Exclude checks
Unexpected spaces found. Open
$error = ERR_WRONG_TRUST_PATH;
- Exclude checks
Unexpected spaces found. Open
$vars['TRUST_PATH'] = '';
- Exclude checks
Unexpected spaces found. Open
$name = htmlspecialchars( $name, ENT_QUOTES );
- Exclude checks
Unexpected spaces found. Open
$label = htmlspecialchars( $label );
- Exclude checks
Unexpected spaces found. Open
$error = ERR_NO_TRUST_PATH;
- Exclude checks
Unexpected spaces found. Open
return false;
- Exclude checks
Unexpected spaces found. Open
$field = "<label for='$name'>$label</label>\n";
- Exclude checks
Unexpected spaces found. Open
return $field;
- Exclude checks
Unexpected spaces found. Open
$error = ERR_INVALID_TRUST_PATH;
- Exclude checks