writesdown/app-cms

View on GitHub

Showing 107 of 233 total issues

Function reset has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        reset: function()
        {
            this.mouse = {
                offsetX   : 0,
                offsetY   : 0,
Severity: Minor
Found in public/admin/js/menu.js - About 1 hr to fix

    Function actionIndex has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function actionIndex()
        {
            $config = [];
            $active = [];
            $available = [];
    Severity: Minor
    Found in backend/controllers/WidgetController.php - About 55 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 beforeSave has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function beforeSave($insert)
        {
            if (parent::beforeSave($insert)) {
                if ($this->isNewRecord) {
                    $this->created_at = new Expression('NOW()');
    Severity: Minor
    Found in common/models/User.php - About 55 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 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 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

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

      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 $isValid;
        Severity: Major
        Found in common/components/Json.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

            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

              Function actionView has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function actionView($id = null, $user = null)
                  {
                      $render = '/user/view';
              
                      if ($id) {
              Severity: Minor
              Found in frontend/controllers/UserController.php - About 25 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 actionIndex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function actionIndex($id = null, $slug = null)
                  {
                      $render = 'index';
              
                      if ($id) {
              Severity: Minor
              Found in frontend/controllers/PostController.php - About 25 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 generateResponse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function generateResponse($media)
                  {
                      $metadata = $media->getMeta('metadata');
                      $response = ArrayHelper::merge(ArrayHelper::toArray($media), $metadata);
                      $response['date_formatted'] = Yii::$app->formatter->asDatetime($media->date);
              Severity: Minor
              Found in common/components/MediaUploadHandler.php - About 25 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

              Severity
              Category
              Status
              Source
              Language