GinoPane/oc-blogtaxonomy-plugin

View on GitHub

Showing 18 of 59 total issues

File Plugin.php has 439 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace GinoPane\BlogTaxonomy;

use Event;
Severity: Minor
Found in Plugin.php - About 6 hrs to fix

    Method defineProperties has 90 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function defineProperties(): array
        {
            return array_merge([
    
                //General properties
    Severity: Major
    Found in components/TagList.php - About 3 hrs to fix

      Method addPostTypeAttributes has 83 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function addPostTypeAttributes(Form $form, PostModel $model): void
          {
              $tab = self::LOCALIZATION_KEY . 'navigation.tab.type';
      
              $form->addSecondaryTabFields([
      Severity: Major
      Found in Plugin.php - About 3 hrs to fix

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

            private function addPostTypeAttributes(Form $form, PostModel $model): void
            {
                $tab = self::LOCALIZATION_KEY . 'navigation.tab.type';
        
                $form->addSecondaryTabFields([
        Severity: Minor
        Found in Plugin.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 extendPostModel has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function extendPostModel(): void
            {
                PostModel::extend(function ($model) {
                    $model->morphToMany = [
                        'tags' => [Tag::class, 'name' => Tag::PIVOT_COLUMN]
        Severity: Minor
        Found in Plugin.php - About 1 hr to fix

          Method defineProperties has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function defineProperties(): array
              {
                  return array_merge([
                      'displayEmpty' => [
                          'title'       =>    Plugin::LOCALIZATION_KEY . 'components.series_list.display_empty_title',
          Severity: Minor
          Found in components/SeriesList.php - About 1 hr to fix

            Method extendCategoriesFormFields has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function extendCategoriesFormFields(): void
                {
                    CategoriesController::extendFormFields(function ($form, $model) {
                        if (!$model instanceof CategoryModel) {
                            return;
            Severity: Minor
            Found in Plugin.php - About 1 hr to fix

              Method extendPostsController has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function extendPostsController(): void
                  {
                      PostsController::extendFormFields(function (Form $form, $model) {
                          if (!$model instanceof PostModel) {
                              return;
              Severity: Minor
              Found in Plugin.php - About 1 hr to fix

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

                    public function defineProperties(): array
                    {
                        return array_merge([
                            'slug' => [
                                'title'             => Plugin::LOCALIZATION_KEY . 'components.related_posts.post_slug_title',
                Severity: Minor
                Found in components/RelatedPosts.php - About 1 hr to fix

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

                      private function createTaggablesTable()
                      {
                          if (!Schema::hasTable(Tag::PIVOT_TABLE)) {
                              $pivotColumnId = Tag::PIVOT_COLUMN . '_id';
                              $pivotColumnType = Tag::PIVOT_COLUMN . '_type';
                  Severity: Minor
                  Found in updates/create_polymorphic_tag_table.php - About 1 hr to fix

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

                        public function registerNavigation(): void
                        {
                            // Extend the navigation
                            Event::listen('backend.menu.extendItems', function ($manager) {
                                $manager->addSideMenuItems(self::REQUIRED_PLUGIN_RAINLAB_BLOG, 'blog', [
                    Severity: Minor
                    Found in Plugin.php - About 1 hr to fix

                      Method migrateRelatedSeries has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function migrateRelatedSeries()
                          {
                              if (empty($this->migratedSeriesIds) || !Schema::hasTable('pkleindienst_blogseries_related')) {
                                  return;
                              }

                        Function createSynonymsRegExp has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              value: function createSynonymsRegExp(str) {
                                var _this = this;
                        
                                var syn = this.opt.synonyms,
                                    sens = this.opt.caseSensitive ? '' : 'i',
                        Severity: Minor
                        Found in assets/js/jquery.mark.js - About 1 hr to fix

                          Method migratePostSeries has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function migratePostSeries()
                              {
                                  if (empty($this->migratedSeriesIds)) {
                                      return;
                                  }

                            Method getPostFilterProperties has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private function getPostFilterProperties(): array
                                {
                                    return [
                                        'includeCategories' => [
                                            'group'             => Plugin::LOCALIZATION_KEY . 'components.post_list_abstract.filters_group',
                            Severity: Minor
                            Found in classes/PostListFiltersTrait.php - About 1 hr to fix

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

                                  private function queryOrderBy($query, $tagIds)
                                  {
                                      if (array_key_exists($this->orderBy, $this->getOrderByOptions())) {
                                          if ($this->orderBy === 'random') {
                                              $query->inRandomOrder();
                              Severity: Minor
                              Found in components/RelatedPosts.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 $query->whereHas('post_type', function ($query) use ($types) {
                                                      $query->whereIn('id', $types);
                                                  });
                              Severity: Major
                              Found in Plugin.php - About 30 mins to fix

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

                                    private function listTags(): Collection
                                    {
                                        $tags = Tag::listFrontend([
                                            'sort' => $this->orderBy,
                                            'displayEmpty' => $this->displayEmpty,
                                Severity: Minor
                                Found in components/TagList.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