Plugin.php
File Plugin.php
has 439 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
namespace GinoPane\BlogTaxonomy;
use Event;
Method addPostTypeAttributes
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function addPostTypeAttributes(Form $form, PostModel $model): void
{
$tab = self::LOCALIZATION_KEY . 'navigation.tab.type';
$form->addSecondaryTabFields([
Function addPostTypeAttributes
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
Open
private function addPostTypeAttributes(Form $form, PostModel $model): void
{
$tab = self::LOCALIZATION_KEY . 'navigation.tab.type';
$form->addSecondaryTabFields([
- Read upRead up
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
Open
private function extendPostModel(): void
{
PostModel::extend(function ($model) {
$model->morphToMany = [
'tags' => [Tag::class, 'name' => Tag::PIVOT_COLUMN]
Method extendCategoriesFormFields
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function extendCategoriesFormFields(): void
{
CategoriesController::extendFormFields(function ($form, $model) {
if (!$model instanceof CategoryModel) {
return;
Method extendPostsController
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function extendPostsController(): void
{
PostsController::extendFormFields(function (Form $form, $model) {
if (!$model instanceof PostModel) {
return;
Method registerNavigation
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function registerNavigation(): void
{
// Extend the navigation
Event::listen('backend.menu.extendItems', function ($manager) {
$manager->addSideMenuItems(self::REQUIRED_PLUGIN_RAINLAB_BLOG, 'blog', [
Avoid too many return
statements within this method. Open
Open
return $query->whereHas('post_type', function ($query) use ($types) {
$query->whereIn('id', $types);
});