writesdown/app-cms

View on GitHub

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
Severity: Major
Found in public/admin/js/media.browser.js and 1 other location - About 1 hr to fix
public/admin/js/media.js on lines 33..40

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

Further Reading

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);
Severity: Minor
Found in backend/controllers/UserController.php - About 1 hr to fix

    Method behaviors has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function behaviors()
        {
            return [
                'access' => [
                    'class' => AccessControl::className(),
    Severity: Minor
    Found in backend/controllers/MediaController.php - About 1 hr to fix

      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 */
      Severity: Major
      Found in common/components/BackendBootstrap.php and 1 other location - About 1 hr to fix
      common/components/FrontendBootstrap.php on lines 42..51

      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

      Further Reading

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

          protected function setTime($app)
          {
              /* TIME ZONE */
              $app->timeZone = Option::get('time_zone');
      
      
      Severity: Major
      Found in common/components/FrontendBootstrap.php and 1 other location - About 1 hr to fix
      common/components/BackendBootstrap.php on lines 42..50

      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

      Further Reading

      Method actionIndex has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function actionIndex($id = null, $slug = null)
          {
              $render = 'index';
      
              if ($id) {
      Severity: Minor
      Found in frontend/controllers/PostController.php - About 1 hr to fix

        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) {
        Severity: Minor
        Found in frontend/controllers/UserController.php - About 1 hr to fix

          Method up has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function up()
              {
                  $tableOptions = null;
          
                  if ($this->db->driverName === 'mysql') {
          Severity: Minor
          Found in console/migrations/m000000_000014_post_comment.php - About 1 hr to fix

            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();
            Severity: Minor
            Found in frontend/controllers/MediaController.php - About 1 hr to fix

              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);
                      }
              Severity: Minor
              Found in common/components/MediaUploadHandler.php - About 1 hr to fix

                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]);
                Severity: Minor
                Found in common/models/search/User.php - About 1 hr to fix

                  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)) {
                  Severity: Minor
                  Found in modules/sitemap/backend/controllers/DefaultController.php - About 1 hr to fix

                    Method actionIndex has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function actionIndex()
                        {
                            $config = [];
                            $active = [];
                            $available = [];
                    Severity: Minor
                    Found in backend/controllers/WidgetController.php - About 1 hr to fix

                      Method behaviors has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function behaviors()
                          {
                              return [
                                  'access' => [
                                      'class' => AccessControl::className(),
                      Severity: Minor
                      Found in backend/controllers/WidgetController.php - About 1 hr to fix

                        Method run has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function run()
                            {
                                echo $this->beforeWidget;
                        
                                if ($this->title) {
                        Severity: Minor
                        Found in widgets/meta/MetaWidget.php - About 1 hr to fix

                          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');
                          Severity: Minor
                          Found in backend/controllers/MediaBrowserController.php - About 1 hr to fix

                            Method actionView has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function actionView($id = null, $slug = null)
                                {
                                    $render = 'view';
                            
                                    if ($id) {
                            Severity: Minor
                            Found in frontend/controllers/TermController.php - About 1 hr to fix

                              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) {
                              Severity: Minor
                              Found in common/models/BaseComment.php - About 1 hr to fix

                                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'])) {
                                Severity: Minor
                                Found in backend/controllers/MenuController.php - About 1 hr 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 10 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    public function actionUpdate($id)
                                    {
                                        $model = $this->findModel($id);
                                        $this->getPermission($model);
                                        $postType = $model->postType;
                                Severity: Minor
                                Found in backend/controllers/PostController.php - About 1 hr 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