Showing 419 of 419 total issues
Method process
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process($email, $fromName, $fromEmail, $maxAttempts)
{
try {
if ($this->send($email, $fromName, $fromEmail)) {
$this
Method send
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function send()
{
$transaction = static::getDb()->beginTransaction();
try {
$this->sender_id = User::loggedId();
Method actionSortCategory
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function actionSortCategory()
{
if (!Yii::$app->request->isAjax) {
return $this->redirect(['admin/categories']);
}
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?= $form->field($model, 'newPassword')->passwordInput([
'placeholder' => Yii::t('podium/view', "Leave empty if you don't want to change it"),
'data-container' => 'body',
'data-toggle' => 'popover',
'data-placement' => 'right',
- 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 111.
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
<?= $form->field($model, 'new_email')->textInput([
'placeholder' => Yii::t('podium/view', "Leave empty if you don't want to change it"),
'data-container' => 'body',
'data-toggle' => 'popover',
'data-placement' => 'right',
- 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 111.
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
The class Podium has 17 fields. Consider redesigning Podium to keep the number of fields under 15. Open
class Podium extends Module implements BootstrapInterface
{
/**
* @var int Admin account ID if $userComponent is not set to true.
*/
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
Method actionMods
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function actionMods($id = null)
{
$mod = null;
$moderators = User::find()->where(['role' => User::ROLE_MODERATOR])->indexBy('id')->all();
if (is_numeric($id) && $id > 0) {
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($post->thread->locked == 1 && !User::can(Rbac::PERM_UPDATE_THREAD, ['item' => $post->thread])) {
$this->info(Yii::t('podium/flash', 'This thread is locked.'));
return $this->redirect([
'forum/thread',
'cid' => $post->forum->category->id,
- 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 110.
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 ($post->thread->locked == 1 && !User::can(Rbac::PERM_UPDATE_THREAD, ['item' => $post->thread])) {
$this->info(Yii::t('podium/flash', 'This thread is locked.'));
return $this->redirect([
'forum/thread',
'cid' => $post->forum->category->id,
- 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 110.
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 lastActive
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function lastActive()
{
$last = Podium::getInstance()->podiumCache->get('forum.lastactive');
if ($last === false) {
$time = time() - 15 * 60;
Method podiumEdit
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function podiumEdit()
{
$transaction = static::getDb()->beginTransaction();
try {
if (!$this->save()) {
Method init
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function init()
{
parent::init();
try {
if (!empty($this->module->accessChecker)) {
Method addAdmin
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addAdmin()
{
if ($this->module->userComponent !== true) {
return $this->addInheritedAdmin();
}
Method run
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run()
{
$url = Yii::$app->request->getUrl();
$out = '';
Function podiumDelete
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function podiumDelete()
{
$transaction = static::getDb()->beginTransaction();
try {
if (!$this->delete()) {
- 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 set
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function set($name, $value)
{
try {
if (is_string($name) && (is_string($value) || $value === null)) {
if ($value === 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 actionEditpoll
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function actionEditpoll($cid = null, $fid = null, $tid = null, $pid = null)
{
$poll = Poll::find()->joinWith('thread')->where([
Poll::tableName() . '.id' => $pid,
Poll::tableName() . '.thread_id' => $tid,
- 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 tooMany
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function tooMany($userId)
{
$sessionKey = 'messages.' . $userId;
if (Yii::$app->session->has($sessionKey)) {
$sentAlready = explode('|', Yii::$app->session->get($sessionKey));
- 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 matchRole
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function matchRole($user)
{
if (empty($this->roles)) {
return true;
}
- 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 upgradeCheck
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function upgradeCheck($warnings)
{
if (!User::can(Rbac::ROLE_ADMIN)) {
return 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"