SU-SWS/caw_profile

View on GitHub

Showing 16 of 395 total issues

Method stanford_basic_form_system_theme_settings_alter has 197 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function stanford_basic_form_system_theme_settings_alter(array &$form, FormStateInterface $form_state) {

  $form['options_settings'] = [
    '#type' => 'fieldset',
    '#title' => t('Theme Specific Settings'),
Severity: Major
Found in themes/stanford_basic/theme-settings.php - About 7 hrs to fix

    File main-menu.island.tsx has 358 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import styled from "styled-components";
    import {useWebComponentEvents} from "./hooks/useWebComponentEvents";
    import {createIslandWebComponent} from 'preact-island'
    import {useState, useEffect, useRef, useCallback} from 'preact/hooks';
    import {deserialize} from "./tools/deserialize";
    Severity: Minor
    Found in themes/stanford_basic/decoupled-menu/src/main-menu.island.tsx - About 4 hrs to fix

      Function onContentImport has a Cognitive Complexity of 30 (exceeds 10 allowed). Consider refactoring.
      Open

        public function onContentImport(ImportEvent $event): void {
          /** @var \Drupal\file\FileInterface $entity */
          foreach ($event->getImportedEntities() as $entity) {
            if ($entity->getEntityTypeId() == 'consumer') {
              $entity->set('secret', md5(random_int(0, 99999)));
      Severity: Minor
      Found in src/EventSubscriber/EventSubscriber.php - About 3 hrs 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 fetch has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        fetch() {
          try {
            switch (this.what) {
              case 'first':
                return this.item.parentNode.firstElementChild.firstChild;
      Severity: Major
      Found in themes/stanford_basic/src/js/components/nav/ElementFetcher.js - About 2 hrs to fix

        Function attach has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          attach(context, settings) {
            (function ($, once) {
              // Validate there is a skip link anchor for the main content. If not,
              // default to #page-content.
              var $mc = $('#main-content', context).length;
        Severity: Major
        Found in themes/stanford_basic/src/js/stanford_basic.behavior.js - About 2 hrs to fix

          Function MainMenu has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const MainMenu = ({}) => {
            useWebComponentEvents(islandName)
          
            const [menuItems, setMenuItems] = useState<MenuContentItem[]>([]);
            const [menuOpen, setMenuOpen] = useState<boolean>(false);
          Severity: Major
          Found in themes/stanford_basic/decoupled-menu/src/main-menu.island.tsx - About 2 hrs to fix

            Function buildCssLayersFromEntryPoints has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const buildCssLayersFromEntryPoints = () => {
              return islands.map(({ layer, elementName }) => {
                return {
                  issuerLayer: layer,
                  use: [
            Severity: Minor
            Found in themes/stanford_basic/decoupled-menu/webpack.config.js - About 1 hr to fix

              Method runTask has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                public function runTask(array &$install_state) {
                  $this->state->set('nobots', FALSE);
              
                  $node_pages = [
                    '403_page' => '4b8018dc-49a6-4018-9c54-e8c3e462beee',
              Severity: Minor
              Found in src/Plugin/InstallTask/SiteSettings.php - About 1 hr to fix

                Method getSnowData has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  protected function getSnowData($site_name) {
                    $api_url = Settings::get('caw_profile_snow_api_url', self::SNOW_API);
                    try {
                      $response = $this->client->request('GET', $api_url, [
                        'query' => ['website_address' => $site_name],
                Severity: Minor
                Found in src/Plugin/InstallTask/SiteSettings.php - About 1 hr to fix

                  Function exec has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    exec() {
                      this.event.preventDefault();
                  
                      // Go to the first subnav item.
                      let node = this.getElement('firstSubnavLink');

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

                      public function loadOverrides($names) {
                        $overrides = [];
                        if (in_array('system.site', $names)) {
                          $overrides['system.site']['page'] = [
                            403 => $this->state->get('caw_profile.403_page'),
                    Severity: Minor
                    Found in src/Config/ConfigOverrides.php - About 1 hr to fix

                      Function constructor has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        constructor(element, options = {}) {
                          // What HTML element this is bound to.
                          this.elem = element;
                      
                          // Set some default options.

                        Function exec has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          exec() {
                            const shifted = event.shiftKey;
                            let firstItem = false;
                            let lastItem = false;
                        
                        

                          Function insert has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                      insert: (styleTag) => {
                                        var styleTarget = styleTag.dataset.styleFor
                          
                                        if (!styleTarget) {
                                          console.error(
                          Severity: Minor
                          Found in themes/stanford_basic/decoupled-menu/webpack.config.js - About 1 hr to fix

                            Function runTask has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
                            Open

                              public function runTask(array &$install_state) {
                                $this->state->set('nobots', FALSE);
                            
                                $node_pages = [
                                  '403_page' => '4b8018dc-49a6-4018-9c54-e8c3e462beee',
                            Severity: Minor
                            Found in src/Plugin/InstallTask/SiteSettings.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 loadOverrides has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
                            Open

                              public function loadOverrides($names) {
                                $overrides = [];
                                if (in_array('system.site', $names)) {
                                  $overrides['system.site']['page'] = [
                                    403 => $this->state->get('caw_profile.403_page'),
                            Severity: Minor
                            Found in src/Config/ConfigOverrides.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