Showing 41 of 1,021 total issues
Method _registerUrlChangeListeners
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function _registerUrlChangeListeners()
{
if (self::getInstance()->getSettings()->createRedirectForUriChange) {
$beforeEvents = [
Elements::EVENT_BEFORE_SAVE_ELEMENT,
Method getMatchingRedirect
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getMatchingRedirect(NotFoundModel $model): RedirectRecord|array|bool
{
Craft::debug("Check if our 404 is matched to a redirect", SeoFields::class);
$parsedUrl = parse_url($model->urlPath);
Method _registerPermissions
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function _registerPermissions()
{
Event::on(
UserPermissions::class,
UserPermissions::EVENT_REGISTER_PERMISSIONS,
Method getAlternate
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAlternate($element = null)
{
if (!$element) {
return false;
}
Method shouldRenderBySiteId
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function shouldRenderBySiteId(Site $site)
{
$data = SeoFields::$plugin->defaultsService->getRecordForSiteId($site->id);
$sitemapSettings = Json::decode($data->sitemap);
if (!$sitemapSettings) {
Function getSitesMenu
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function getSitesMenu()
{
$sites = [
0 => Craft::t('seo-fields', 'All Sites'),
];
- 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 init
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function init()
{
parent::init();
self::$plugin = $this;
Method migrate
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function migrate($oldHandle = 'seo', $newHandle = 'newSeo', $siteId = null, $titleSeperator = null)
{
$this->titleSeperator = $titleSeperator;
$query = Entry::find();
$sites = [];
Function import
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function import($data, $settings)
{
App::maxPowerCaptain();
$patternCol = $settings['patternCol'];
$redirectCol = $settings['redirectCol'];
- 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
Function getSeoFromContent
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getSeoFromContent($context, $handle)
{
$meta = null;
$element = null;
- 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
Function actionSave
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function actionSave()
{
$id = $this->request->getBodyParam('redirectId');
$record = $this->request->getBodyParam('record');
if ($id) {
- 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
Function handleNotFound
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function handleNotFound(Request $request, Site $site)
{
try {
$notFoundRecord = NotFoundRecord::findOne(['fullUrl' => $request->getAbsoluteUrl(), 'urlPath' => $request->getUrl(), 'siteId' => $site->id]);
if ($notFoundRecord) {
- 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
Function redirect
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function redirect(RedirectModel|RedirectRecord|array $redirect)
{
try {
if (is_array($redirect)) {
$url = $redirect['url'];
- 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
Function migrate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function migrate($oldHandle = 'seo', $newHandle = 'newSeo', $siteId = null, $titleSeperator = null)
{
$this->titleSeperator = $titleSeperator;
$query = Entry::find();
$sites = [];
- 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
Function getElementUrls
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function getElementUrls(Element $element)
{
$uris = [];
if (!ElementHelper::isDraftOrRevision($element) && $element->id) {
foreach (Craft::$app->getSites()->getAllSites(true) as $site) {
- 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
Function shouldRenderBySiteId
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function shouldRenderBySiteId(Site $site)
{
$data = SeoFields::$plugin->defaultsService->getRecordForSiteId($site->id);
$sitemapSettings = Json::decode($data->sitemap);
if (!$sitemapSettings) {
- 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
Function getSchema
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getSchema(Element $element = null)
{
if (!$element) {
return null;
}
- 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
Function getSitemapData
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getSitemapData($siteId, $type, $sectionId)
{
$settings = $this->getSettingsBySiteId($siteId);
$data = [];
switch ($type) {
- 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
Function getCpNavItem
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getCpNavItem(): ?array
{
$subNavs = [];
$navItem = parent::getCpNavItem();
$navItem['label'] = $this->getSettings()->pluginLabel;
- 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
Function execute
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function execute($queue): void
{
$model = new SeoFieldModel();
if ($this->entry->metaTitle) {
$model->metaTitle = $this->entry->metaTitle;
- 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"