writesdown/app-cms

View on GitHub

Showing 233 of 233 total issues

Function correctExifRotation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    protected function correctExifRotation($image, $filePath)
    {
        if (!function_exists('exif_read_data')) {
            return false;
        }
Severity: Minor
Found in common/components/MediaUploadHandler.php - About 45 mins to fix

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 actionDeleteMenuItem has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function actionDeleteMenuItem()
    {
        /* @var $children \common\models\MenuItem[] */
        if ($id = Yii::$app->request->post('id')) {
            $model = $this->findMenuItem($id);
Severity: Minor
Found in backend/controllers/MenuController.php - About 45 mins to fix

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 actionDelete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function actionDelete($theme)
    {
        if ($theme !== Option::get('theme')) {

            foreach (ArrayHelper::getValue($this->getConfig($theme), 'delete', []) as $type) {
Severity: Minor
Found in backend/controllers/ThemeController.php - About 45 mins to fix

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 get has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function get($id = null, $printResponse = self::PRINT_RESPONSE)
    {
        $content = [];

        if ($id && $media = $this->findMedia($id)) {
Severity: Minor
Found in common/components/MediaUploadHandler.php - About 45 mins to fix

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

Consider simplifying this complex logical expression.
Open

        if (!$this->postType
            || !Yii::$app->user->can($this->postType->permission)
            || (!Yii::$app->user->can('editor') && Yii::$app->user->id !== $this->author)
            || (!Yii::$app->user->can('author') && $this->status === self::STATUS_REVIEW)
        ) {
Severity: Major
Found in common/models/Post.php - About 40 mins to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                mouse.offsetX = e.offsetX !== undefined ? e.offsetX : e.pageX - target.offset().left;
    Severity: Minor
    Found in public/admin/js/menu.js and 1 other location - About 40 mins to fix
    public/admin/js/menu.js on lines 259..259

    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 48.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                mouse.offsetY = e.offsetY !== undefined ? e.offsetY : e.pageY - target.offset().top;
    Severity: Minor
    Found in public/admin/js/menu.js and 1 other location - About 40 mins to fix
    public/admin/js/menu.js on lines 258..258

    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 48.

    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

    Further Reading

    Function init has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function init()
        {
            switch ($this->tag) {
                case 'div':
                    $this->tagItem = 'div';
    Severity: Minor
    Found in frontend/widgets/comment/BaseComment.php - About 35 mins to fix

    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 actionInstall has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function actionInstall($theme)
        {
            foreach (ArrayHelper::getValue($this->getConfig(Option::get('theme')), 'uninstall', []) as $type) {
                try {
                    Yii::createObject($type);
    Severity: Minor
    Found in backend/controllers/ThemeController.php - About 35 mins to fix

    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 actionCreate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function actionCreate()
        {
            $model = new PostType();
            $taxonomies = ArrayHelper::map(Taxonomy::find()->all(), 'id', 'name');
    
    
    Severity: Minor
    Found in backend/controllers/PostTypeController.php - About 35 mins to fix

    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 renderComments has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function renderComments($comments, $depth = 0)
        {
            foreach ($comments as $comment) {
                echo Html::beginTag($this->tagItem, $this->itemOptions);
                $this->displayComment($comment, $depth);
    Severity: Minor
    Found in frontend/widgets/comment/BaseComment.php - About 35 mins to fix

    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 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function actionUpdate($id)
        {
            $model = $this->findModel($id);
            $taxonomies = ArrayHelper::map(Taxonomy::find()->all(), 'id', 'name');
    
    
    Severity: Minor
    Found in backend/controllers/PostTypeController.php - About 35 mins to fix

    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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function upMeta($name, $value)
        {
            /* @var $model \common\models\MediaMeta */
            $model = MediaMeta::findOne(['name' => $name, 'media_id' => $this->id]);
    
    
    Severity: Minor
    Found in common/models/Media.php and 1 other location - About 30 mins to fix
    common/models/Post.php on lines 285..297

    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 91.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function upMeta($name, $value)
        {
            /* @var $model \common\models\PostMeta */
            $model = PostMeta::findOne(['name' => $name, 'post_id' => $this->id]);
    
    
    Severity: Minor
    Found in common/models/Post.php and 1 other location - About 30 mins to fix
    common/models/Media.php on lines 238..250

    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 91.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        protected function findModelBySlug($slug)
        {
            $model = Post::find()
                ->andWhere(['slug' => $slug, 'status' => 'publish'])
                ->andWhere(['<=', 'date', date('Y-m-d H:i:s')])
    Severity: Minor
    Found in frontend/controllers/PostController.php and 1 other location - About 30 mins to fix
    frontend/controllers/PostController.php on lines 124..136

    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 90.

    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

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

            var $this = $(this),
                child = $this.closest('.dd-item').find('.dd-list'),
                parent = $this.closest('.dd-list');
    Severity: Minor
    Found in public/admin/js/menu.js and 2 other locations - About 30 mins to fix
    public/admin/js/site.js on lines 133..135
    public/admin/js/site.js on lines 140..142

    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 45.

    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

    Further Reading

    Avoid too many return statements within this method.
    Open

            return $this->render('create', [
                'model' => $model,
                'errors' => $errors,
            ]);
    Severity: Major
    Found in backend/controllers/WidgetController.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return $this->render('create', [
                  'model' => $model,
                  'error' => $errors,
              ]);
      Severity: Major
      Found in backend/controllers/ModuleController.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return $this->redirect(['/site/not-found']);
        Severity: Major
        Found in modules/sitemap/frontend/controllers/DefaultController.php - About 30 mins to fix

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                  var $this = $(this),
                      container = $this.parents('.box').find('.checkbox'),
                      form   = $this.parents('.input-group');
          Severity: Minor
          Found in public/admin/js/site.js and 2 other locations - About 30 mins to fix
          public/admin/js/menu.js on lines 558..560
          public/admin/js/site.js on lines 133..135

          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 45.

          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

          Further Reading

          Severity
          Category
          Status
          Source
          Language