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;
Method defineProperties
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function defineProperties(): array
{
return array_merge([
//General properties
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([
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([
- 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
private function extendPostModel(): void
{
PostModel::extend(function ($model) {
$model->morphToMany = [
'tags' => [Tag::class, 'name' => Tag::PIVOT_COLUMN]
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',
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;
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;
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',
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';
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', [
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',
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',
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();
- 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
Avoid too many return
statements within this method. Open
return $query->whereHas('post_type', function ($query) use ($types) {
$query->whereIn('id', $types);
});
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,
- 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"