Showing 419 of 419 total issues
Function updateInheritedAccount
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function updateInheritedAccount()
{
if (!Podium::getInstance()->user->isGuest) {
$userNameField = Podium::getInstance()->userNameField;
if ($userNameField === null) {
- 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 updateWords
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function updateWords()
{
try {
$vocabulary = [];
$allWords = $this->prepareWords();
- 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 podiumDelete
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function podiumDelete()
{
$transaction = static::getDb()->beginTransaction();
try {
if (!$this->delete()) {
Method actionIgnore
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function actionIgnore($id = null)
{
if (Podium::getInstance()->user->isGuest) {
return $this->redirect(['forum/index']);
}
Method updateModeratorForMany
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateModeratorForMany($newForums = [], $oldForums = [])
{
$transaction = static::getDb()->beginTransaction();
try {
$add = [];
Method nextStep
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function nextStep()
{
$currentStep = Yii::$app->session->get(self::SESSION_KEY, 0);
if ($currentStep === 0) {
Yii::$app->session->set(self::SESSION_STEPS, count($this->versionSteps));
Avoid using undefined variables such as '$properties' which will lead to PHP notices. Open
$properties['duration'] = $duration;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$properties' which will lead to PHP notices. Open
$properties['id'] = $this->_cachePrefix . $key;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$properties' which will lead to PHP notices. Open
$cache = FragmentCache::begin($properties);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
The class User has 45 public methods and attributes. Consider reducing the number of public items to less than 45. Open
class User extends UserActiveRecord
{
/**
* Roles.
*/
- Read upRead up
- Exclude checks
ExcessivePublicCount
Since: 0.1
A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.
Example
public class Foo {
public $value;
public $something;
public $var;
// [... more more public attributes ...]
public function doWork() {}
public function doMoreWork() {}
public function doWorkAgain() {}
// [... more more public methods ...]
}
Source https://phpmd.org/rules/codesize.html#excessivepubliccount
Avoid using undefined variables such as '$properties' which will lead to PHP notices. Open
$properties['view'] = $view;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Method updateWords
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function updateWords()
{
try {
$vocabulary = [];
$allWords = $this->prepareWords();
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php if (empty($items)): ?>
<h3><?= Yii::t('podium/view', 'No categories have been added yet.') ?></h3>
<?php else: ?>
<?= Sortable::widget([
'showHandle' => true,
- 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 103.
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
<?php if (empty($items)): ?>
<h3><?= Yii::t('podium/view', 'No forums have been added yet in this category.') ?></h3>
<?php else: ?>
<?= Sortable::widget([
'showHandle' => true,
- 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 103.
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
Method getIcon
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getIcon()
{
$icon = self::ICON_NO_NEW;
$append = false;
Method actionForum
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function actionForum($cid = null, $id = null, $slug = null, $toggle = null)
{
$filters = Yii::$app->session->get('forum-filters');
if (in_array(strtolower($toggle), ['new', 'edit', 'hot', 'pin', 'lock', 'all'])) {
if (strtolower($toggle) == 'all') {
Function actionAdd
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function actionAdd($id = null)
{
if (!Yii::$app->request->isAjax) {
return $this->redirect(['forum/index']);
}
- 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 podiumReport
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function podiumReport($post = null)
{
try {
if (empty($post)) {
throw new Exception('Reported post missing');
- 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 update
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function update($data)
{
$validator = new StringValidator();
$validator->max = 255;
- 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 timeZones
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function timeZones()
{
$timeZones = [];
$timezone_identifiers = DateTimeZone::listIdentifiers();
- 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"