Showing 181 of 181 total issues
File GwikiPage.php
has 1739 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace XoopsModules\Gwiki;
use const _MI_GWIKI_WIKI404;
Function showDOMNode
has a Cognitive Complexity of 110 (exceeds 5 allowed). Consider refactoring. Open
function showDOMNode(&$out, DOMNode $domNode, $nest, $lt, $ld, $nop)
{
foreach ($domNode->childNodes as $node) {
switch ($node->nodeName) {
case 'a':
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($cnt > 0) {
$sql = 'SELECT image_file FROM ' . $xoopsDB->prefix('gwiki_page_images');
$sql .= ' WHERE keyword NOT IN (SELECT keyword from ' . $xoopsDB->prefix('gwiki_pages') . ')';
$result = $xoopsDB->query($sql);
while (false !== ($f = $xoopsDB->fetchArray($result))) {
- 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 399.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($cnt > 0) {
$sql = 'SELECT image_file FROM ' . $xoopsDB->prefix('gwiki_page_images');
$sql .= ' WHERE keyword NOT IN (SELECT keyword from ' . $xoopsDB->prefix('gwiki_pages') . ')';
$result = $xoopsDB->query($sql);
while (false !== ($f = $xoopsDB->fetchArray($result))) {
- 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 399.
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
File wizard.php
has 631 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* wizard.php - wiki page creation wizard
*
* @copyright Copyright © 2013 geekwright, LLC. All rights reserved.
GwikiPage
has 67 functions (exceeds 20 allowed). Consider refactoring. Open
class GwikiPage
{
//------------------------------------------------------------
// Properties - public, protected, and private
//------------------------------------------------------------
File prefixes.php
has 514 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* admin/prefixes.php - manage wiki namespaces
*
Function truncateHtml
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
{
if ($considerHtml) {
// if the plain text is shorter than the maximum length, return the whole text
if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
- 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 showAttachments
has 189 lines of code (exceeds 25 allowed). Consider refactoring. Open
function showAttachments()
{
global $xoopsDB, $wikiPage;
$dir = \basename(\dirname(__DIR__));
/*
File pages.php
has 472 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* admin/pages.php - manage wiki page revision
*
* @copyright Copyright © 2013 geekwright, LLC. All rights reserved.
Method __construct
has 182 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($wordsPer = 100)
{
$this->wordsPerParagraph = $wordsPer;
$this->wordsPerSentence = 24.460;
$this->words = [
Method showDOMNode
has 181 lines of code (exceeds 25 allowed). Consider refactoring. Open
function showDOMNode(&$out, DOMNode $domNode, $nest, $lt, $ld, $nop)
{
foreach ($domNode->childNodes as $node) {
switch ($node->nodeName) {
case 'a':
File blocks.php
has 449 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* blocks/blocks.php
*
* @param mixed $options
Method renderPage
has 161 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function renderPage($body = null, $title = null)
{
if (empty($body)) {
$body = $this->body;
}
Function checkEdit
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
public function checkEdit()
{
global $xoopsUser, $xoopsDB;
$mayEdit = false;
- 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 xoops_module_update_gwiki
has 140 lines of code (exceeds 25 allowed). Consider refactoring. Open
function xoops_module_update_gwiki(\XoopsModule $module, $old_version)
{
global $xoopsDB;
$error = false;
Function renderLists
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
private function renderLists($matches)
{
$lines = \explode("\n", $matches[0]);
$last = '';
foreach ($lines as $i => $line) {
- 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
Function fbcom_plugin
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
function fbcom_plugin(&$metas, $plugin_env)
{
global $xoopsDB;
$helper = Helper::getInstance();
- 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
Function addRevision
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
public function addRevision($leave_inactive = false)
{
global $xoopsDB;
$page = $this->escapeForDB($this->keyword);
- 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
Function xoops_module_update_gwiki
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
function xoops_module_update_gwiki(\XoopsModule $module, $old_version)
{
global $xoopsDB;
$error = false;
- 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"