GinoPane/oc-blogtaxonomy-plugin

View on GitHub
Plugin.php

Summary

Maintainability
D
2 days
Test Coverage

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

              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

                There are no issues that match your filters.

                Category
                Status