Showing 41 of 1,021 total issues
File SeoFields.php
has 394 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
/**
* SEO Fields plugin for Craft CMS 3.x
*
* Fields for your SEO & OG data
File SeoFieldModel.php
has 329 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
namespace studioespresso\seofields\models;
use Craft;
File SitemapService.php
has 323 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
namespace studioespresso\seofields\services;
use Craft;
SeoFieldModel
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class SeoFieldModel extends Model
{
public $metaTitle;
public $metaDescription;
Method actionRedirects
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function actionRedirects()
{
$sort = $this->request->getQueryParam('sort');
$search = $this->request->getQueryParam('search');
if (!$sort) {
Function _registerUrlChangeListeners
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Open
private function _registerUrlChangeListeners()
{
if (self::getInstance()->getSettings()->createRedirectForUriChange) {
$beforeEvents = [
Elements::EVENT_BEFORE_SAVE_ELEMENT,
- 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 actionNotFound
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function actionNotFound()
{
$sort = $this->request->getQueryParam('sort');
$search = $this->request->getQueryParam('search');
if (!$sort) {
Method createTables
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function createTables()
{
$tablesCreated = false;
$tableSchema = Craft::$app->db->schema->getTableSchema(DefaultsRecord::tableName());
if ($tableSchema === null) {
Method _registerCpListeners
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function _registerCpListeners()
{
Event::on(
Sites::class,
Sites::EVENT_AFTER_SAVE_SITE,
Method _addElementsToSitemap
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function _addElementsToSitemap($entries, $settings)
{
$data = [];
$data[] = '<?xml version="1.0" encoding="UTF-8"?>';
$data[] = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9">';
Method getCpNavItem
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function getCpNavItem(): ?array
{
$subNavs = [];
$navItem = parent::getCpNavItem();
$navItem['label'] = $this->getSettings()->pluginLabel;
Method getSitemapData
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function getSitemapData($siteId, $type, $sectionId)
{
$settings = $this->getSettingsBySiteId($siteId);
$data = [];
switch ($type) {
Function _addElementsToSitemap
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
private function _addElementsToSitemap($entries, $settings)
{
$data = [];
$data[] = '<?xml version="1.0" encoding="UTF-8"?>';
$data[] = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9">';
- 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 getSchema
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function getSchema(Element $element = null)
{
if (!$element) {
return null;
}
Method safeUp
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function safeUp()
{
$tablesCreated = false;
$tableSchema = Craft::$app->db->schema->getTableSchema(RedirectRecord::tableName());
if ($tableSchema === null) {
Method handleNotFound
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function handleNotFound(Request $request, Site $site)
{
try {
$notFoundRecord = NotFoundRecord::findOne(['fullUrl' => $request->getAbsoluteUrl(), 'urlPath' => $request->getUrl(), 'siteId' => $site->id]);
if ($notFoundRecord) {
Method getSitemapIndex
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function getSitemapIndex($data)
{
$currentSite = Craft::$app->getSites()->getCurrentSite();
$cacheDependency = new TagDependency([
'tags' => [
Method import
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function import($data, $settings)
{
App::maxPowerCaptain();
$patternCol = $settings['patternCol'];
$redirectCol = $settings['redirectCol'];
Method safeUp
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function safeUp()
{
$tablesCreated = false;
$tableSchema = Craft::$app->db->schema->getTableSchema(NotFoundRecord::tableName());
if ($tableSchema === null) {
Method addForeignKeys
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function addForeignKeys()
{
// $name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null)
$this->addForeignKey(
$this->db->getForeignKeyName(DefaultsRecord::tableName(), 'siteId'),