Showing 242 of 242 total issues
Identical blocks of code found in 2 locations. Consider refactoring. Open
for ( $j = 0; $j < $opcount; $j ++ ) {
$optval = defined( $options[ $j ]->getVar( 'confop_value' ) ) ? constant( $options[ $j ]->getVar( 'confop_value' ) ) : $options[ $j ]->getVar( 'confop_value' );
$optkey = defined( $options[ $j ]->getVar( 'confop_name' ) ) ? constant( $options[ $j ]->getVar( 'confop_name' ) ) : $options[ $j ]->getVar( 'confop_name' );
$ele->addOption( $optval, $optkey . $addBr );
- 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 148.
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
Function _readEndCentralDir
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public function _readEndCentralDir(&$p_central_dir)
{
$v_result=1;
// ----- Go to the end of the zip file
- 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 _readEndCentralDir
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _readEndCentralDir(&$p_central_dir)
{
$v_result=1;
// ----- Go to the end of the zip file
Method altsys_oninstall_base
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
function altsys_oninstall_base( $module, $mydirname ) {
// transactions on module install
global $ret; // TODO :-D
Function draw_repost_form
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function draw_repost_form(string $area = '' ) {
// Notify which file is broken
if ( headers_sent() ) {
restore_error_handler();
- 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 diff
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function diff( $from_lines, $to_lines ) {
$n_from = count( $from_lines );
$n_to = count( $to_lines );
$this->xchanged = $this->ychanged = [];
Function triggerEvent
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public function triggerEvent($mydirname, $mytrustdirname, $category, $item_id, $event, array $extra_tags = [], array $user_list = [], $omit_user_id = null)
{
$module_handler =& xoops_gethandler('module');
$module =& $module_handler->getByDirname($mydirname);
- 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 _shiftBoundaries
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _shiftBoundaries( $lines, &$changed, $other_changed ) {
$i = 0;
$j = 0;
assert( count( $lines ) == count( $changed ) );
Method _diag
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _diag( $xoff, $xlim, $yoff, $ylim, $nchunks ) {
$flip = false;
if ( $xlim - $xoff > $ylim - $yoff ) {
/* Things seems faster (I'm not sure I understand why) when the
Method renderCell4BlockPosition
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function renderCell4BlockPosition( $block_data ) {
$bid = (int) $block_data['bid'];
$side = (int) $block_data['side'];
$visible = (int) $block_data['visible'];
Function _tool_PathInclusion
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function _tool_PathInclusion($p_dir, $p_path)
{
$v_result = 1;
// ----- Explode dir and path by directory separator
- 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 altsys_admin_in_theme_in_last
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
function altsys_admin_in_theme_in_last( $contents = null ) {
global $xoops_admin_contents, $xoopsConfig, $xoopsModule, $xoopsUser, $xoopsUserIsAdmin, $xoopsLogger, $altsysModuleConfig, $altsysModuleId;
if ( ! isset( $contents ) ) {
while ( ob_get_level() ) {
Method list_blocks
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function list_blocks() {
global $xoopsGTicket;
// main query
$sql = 'SELECT * FROM ' . $this->db->prefix( 'newblocks' ) . " WHERE mid='$this->target_mid' ORDER BY visible DESC,side,weight";
Method render
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function render() {
global $xoopsGTicket;
// load all child ids for javascript codes
foreach ( array_keys( $this->_itemTree ) as $item_id ) {
Method check
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function check(bool $post = true, string $area = '', bool $allow_repost = true ) {
global $xoopsModule;
$this->_errors = [];
Method altsys_onupdate_base
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
function altsys_onupdate_base( $module, $mydirname ) {
// transactions on module update
global $msgs; // TODO :-D
Method read
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function read($resource, $mydirname, $mytrustdirname = null, bool $read_once = true)
{
$d3file = XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/mytrustdirname.php';
if (empty($mytrustdirname) && is_file($d3file)) {
Method update_block
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function update_block( $bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $options = [] ) {
global $xoopsConfig;
//HACK by domifara
if ( defined( 'XOOPS_CUBE_LEGACY' ) ) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ( ! $tplfile_handler->insert( $tplfile ) ) {
$msgs[] = '<span style="color:#ff0000;">ERROR: Could not insert template <b>' . htmlspecialchars( $mydirname . '_' . $file ) . '</b> to the database.</span>';
} else {
$tplid = $tplfile->getVar( 'tpl_id' );
$msgs[] = 'Template <b>' . htmlspecialchars( $mydirname . '_' . $file ) . '</b> added to the database. (ID: <b>' . $tplid . '</b>)';
- 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 120.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ( ! $tplfile_handler->insert( $tplfile ) ) {
$ret[] = '<span style="color:#ff0000;">ERROR: Could not insert template <b>' . htmlspecialchars( $mydirname . '_' . $file ) . '</b> to the database.</span><br>';
} else {
$tplid = $tplfile->getVar( 'tpl_id' );
$ret[] = 'Template <b>' . htmlspecialchars( $mydirname . '_' . $file ) . '</b> added to the database. (ID: <b>' . $tplid . '</b>)<br>';
- 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 120.
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