Showing 233 of 233 total issues
Identical blocks of code found in 2 locations. Consider refactoring. Open
do {
if ($(node).hasClass('dropzone')) {
found = true;
foundDropzone = $(node);
break
- 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 60.
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 actionBulkAction
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function actionBulkAction()
{
if (Yii::$app->request->post('action') === 'active') {
foreach (Yii::$app->request->post('ids', []) as $id) {
$model = $this->findModel($id);
Method behaviors
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
Identical blocks of code found in 2 locations. Consider refactoring. Open
protected function setTime($app)
{
/* TIME ZONE */
$app->timeZone = Option::get('time_zone');
/* DATE TIME */
- 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 105.
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
protected function setTime($app)
{
/* TIME ZONE */
$app->timeZone = Option::get('time_zone');
- 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 105.
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 actionIndex
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function actionIndex($id = null, $slug = null)
{
$render = 'index';
if ($id) {
Method actionView
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function actionView($id = null, $user = null)
{
$render = '/user/view';
if ($id) {
Method up
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function up()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
Method actionView
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function actionView($id = null, $slug = null)
{
$render = 'view';
$comment = new Comment();
Method post
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function post($printResponse = self::PRINT_RESPONSE)
{
if (Yii::$app->request->get('delete') && $id = Yii::$app->request->get('id')) {
return $this->delete($id, $printResponse);
}
Method search
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function search($params)
{
$query = UserModel::find();
$query->andWhere(['<>', 'id', Yii::$app->user->id]);
Method beforeAction
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function beforeAction($action)
{
/* @var $postType \common\models\PostType */
/* @var $taxonomy \common\models\Taxonomy */
if (parent::beforeAction($action)) {
Method actionIndex
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function actionIndex()
{
$config = [];
$active = [];
$available = [];
Method behaviors
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
Method run
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run()
{
echo $this->beforeWidget;
if ($this->title) {
Method getMediaImage
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getMediaImage($media)
{
$result = '';
$model = $this->findModel(ArrayHelper::getValue($media, 'id'));
$meta = $model->getMeta('metadata');
Method actionView
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function actionView($id = null, $slug = null)
{
$render = 'view';
if ($id) {
Method beforeSave
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function beforeSave($insert)
{
if (parent::beforeSave($insert)) {
if ($this->isNewRecord) {
if (!Yii::$app->user->isGuest) {
Function saveMenuItem
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function saveMenuItem($menuOrder, $menuParent = 0)
{
foreach ($menuOrder as $key => $order) {
$menuItem = Yii::$app->request->post('MenuItem')[$order['id']];
if ($model = $this->findMenuItem($order['id'])) {
- 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 actionUpdate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function actionUpdate($id)
{
$model = $this->findModel($id);
$this->getPermission($model);
$postType = $model->postType;
- 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"