studioespresso/craft-seo-fields

View on GitHub

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,
Severity: Minor
Found in src/SeoFields.php - About 1 hr to fix

    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);
    
    
    Severity: Minor
    Found in src/services/NotFoundService.php - About 1 hr to fix

      Method _registerPermissions has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function _registerPermissions()
          {
              Event::on(
                  UserPermissions::class,
                  UserPermissions::EVENT_REGISTER_PERMISSIONS,
      Severity: Minor
      Found in src/SeoFields.php - About 1 hr to fix

        Method getAlternate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getAlternate($element = null)
            {
                if (!$element) {
                    return false;
                }
        Severity: Minor
        Found in src/models/SeoFieldModel.php - About 1 hr to fix

          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) {
          Severity: Minor
          Found in src/services/SitemapService.php - About 1 hr to fix

            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'),
                    ];
            Severity: Minor
            Found in src/controllers/RedirectsController.php - About 1 hr 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 init has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function init()
                {
                    parent::init();
                    self::$plugin = $this;
            
            
            Severity: Minor
            Found in src/SeoFields.php - About 1 hr to fix

              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 = [];
              Severity: Minor
              Found in src/services/migrate/Ether.php - About 1 hr to fix

                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'];
                Severity: Minor
                Found in src/services/RedirectService.php - About 55 mins 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

                Function getSeoFromContent has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getSeoFromContent($context, $handle)
                    {
                        $meta = null;
                        $element = null;
                
                
                Severity: Minor
                Found in src/services/RenderService.php - About 55 mins 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

                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) {
                Severity: Minor
                Found in src/controllers/RedirectsController.php - About 45 mins 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

                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) {
                Severity: Minor
                Found in src/services/NotFoundService.php - About 45 mins 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

                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'];
                Severity: Minor
                Found in src/services/RedirectService.php - About 35 mins 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

                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 = [];
                Severity: Minor
                Found in src/services/migrate/Ether.php - About 35 mins 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

                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) {
                Severity: Minor
                Found in src/services/RedirectService.php - About 35 mins 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

                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) {
                Severity: Minor
                Found in src/services/SitemapService.php - About 35 mins 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

                Function getSchema has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getSchema(Element $element = null)
                    {
                        if (!$element) {
                            return null;
                        }
                Severity: Minor
                Found in src/models/SeoFieldModel.php - About 35 mins 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

                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) {
                Severity: Minor
                Found in src/services/SitemapService.php - About 25 mins 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

                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;
                Severity: Minor
                Found in src/SeoFields.php - About 25 mins 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

                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;
                Severity: Minor
                Found in src/jobs/MigrateFieldDataJob.php - About 25 mins 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

                Severity
                Category
                Status
                Source
                Language