writesdown/app-cms

View on GitHub

Showing 107 of 233 total issues

Post has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

class Post extends ActiveRecord
{
    public $username;

    const COMMENT_STATUS_OPEN = 'open';
Severity: Minor
Found in common/models/Post.php - About 2 hrs to fix

    User has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class User extends ActiveRecord implements IdentityInterface
    {
        const STATUS_REMOVED = 0;
        const STATUS_NOT_ACTIVE = 5;
        const STATUS_ACTIVE = 10;
    Severity: Minor
    Found in common/models/User.php - About 2 hrs to fix

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

          public function up()
          {
              $tableOptions = null;
      
              if ($this->db->driverName === 'mysql') {
      Severity: Major
      Found in console/migrations/m000000_000020_module.php - About 2 hrs to fix

        Function actionBulkAction has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            public function actionBulkAction()
            {
                if (Yii::$app->request->post('action') === PostComment::STATUS_APPROVED) {
                    foreach (Yii::$app->request->post('ids', []) as $id) {
                        $this->findModel($id)->updateAttributes(['status' => PostComment::STATUS_APPROVED]);
        Severity: Minor
        Found in backend/controllers/PostCommentController.php - About 2 hrs 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 actionBulkAction has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            public function actionBulkAction()
            {
                if (Yii::$app->request->post('action') === MediaComment::STATUS_APPROVED) {
                    foreach (Yii::$app->request->post('ids', []) as $id) {
                        $this->findModel($id)->updateAttributes(['status' => MediaComment::STATUS_APPROVED]);
        Severity: Minor
        Found in backend/controllers/MediaCommentController.php - About 2 hrs 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 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                init: function()
                {
                    var list = this;
        
                    list.reset();
        Severity: Major
        Found in public/admin/js/menu.js - About 2 hrs to fix

          Method actionCreate has 62 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function actionCreate()
              {
                  $errors = [];
                  $model = new Widget(['scenario' => 'upload']);
          
          
          Severity: Major
          Found in backend/controllers/WidgetController.php - About 2 hrs to fix

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

                public function up()
                {
                    $tableOptions = null;
                    if ($this->db->driverName === 'mysql') {
                        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
            Severity: Major
            Found in console/migrations/m000000_000001_option.php - About 2 hrs to fix

              Method createScaledImage has 61 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function createScaledImage($fileName, $version, $options)
                  {
                      $success = false;
                      $filePath = $this->getFilePath($fileName);
                      $image = Image::getImagine()->open($filePath);
              Severity: Major
              Found in common/components/MediaUploadHandler.php - About 2 hrs to fix

                Function createScaledImage has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function createScaledImage($fileName, $version, $options)
                    {
                        $success = false;
                        $filePath = $this->getFilePath($fileName);
                        $image = Image::getImagine()->open($filePath);
                Severity: Minor
                Found in common/components/MediaUploadHandler.php - About 2 hrs 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

                File Post.php has 267 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                /**
                 * @link http://www.writesdown.com/
                 * @copyright Copyright (c) 2015 WritesDown
                 * @license http://www.writesdown.com/license/
                Severity: Minor
                Found in common/models/Post.php - About 2 hrs to fix

                  File discussion.php has 263 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  /**
                   * @link http://www.writesdown.com/
                   * @author Agiel K. Saputra <13nightevil@gmail.com>
                   * @copyright Copyright (c) 2015 WritesDown
                  Severity: Minor
                  Found in backend/views/setting/discussion.php - About 2 hrs to fix

                    Function setModule has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function setModule($app)
                        {
                            foreach (Module::getActiveModules() as $module) {
                                // Get module backend config.
                                if ($config = $module->getBackendConfig()) {
                    Severity: Minor
                    Found in common/components/BackendBootstrap.php - About 2 hrs 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 setModule has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function setModule($app)
                        {
                            foreach (Module::getActiveModules() as $module) {
                                // Get module backend config.
                                if ($config = $module->getFrontendConfig()) {
                    Severity: Minor
                    Found in common/components/FrontendBootstrap.php - About 2 hrs 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

                    Method actionUpload has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function actionUpload()
                        {
                            $errors = [];
                            $model = new DynamicModel(['file']);
                            $model->addRule(['file'], 'required')
                    Severity: Major
                    Found in backend/controllers/ThemeController.php - About 2 hrs to fix

                      Method displayComment has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function displayComment($comment, $depth = 0)
                          {
                              echo Html::beginTag('div', [
                                  'id' => 'comment-' . $comment->id,
                                  'class' => $comment->child ? 'parent depth-' . $depth : 'depth-' . $depth,
                      Severity: Minor
                      Found in frontend/widgets/comment/BaseComment.php - About 2 hrs to fix

                        Function MediaModal has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            var MediaModal = function (button, options) {
                                this.button = $(button);
                        
                                this.settings = $.extend({
                                    url: 'index.php?media-browser/index',
                        Severity: Minor
                        Found in public/admin/js/media.modal.js - About 1 hr to fix

                          Function actionBulkAction has a Cognitive Complexity of 15 (exceeds 5 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

                          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

                          Method setOptions has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function setOptions($options = [])
                              {
                                  $this->options = [
                                      'script_url' => Yii::$app->request->absoluteUrl,
                                      'upload_dir' => Yii::getAlias('@public/uploads/'),
                          Severity: Minor
                          Found in common/components/MediaUploadHandler.php - About 1 hr to fix

                            Function actionUpload has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    this.actionUpload = function () {
                                        this.upload.fileupload({
                                                url: this.settings.url.upload,
                                                dropZone: this.dropzone,
                                                autoUpload: true,
                            Severity: Minor
                            Found in public/admin/js/media.browser.js - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language