SU-SWS/stanford_profile_helper

View on GitHub

Showing 20 of 706 total issues

Function EventCalendar has 118 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const EventCalendar = () => {
  const apiUrl = (process.env?.LOCAL_DRUPAL ?? '') + '/jsonapi/node/stanford_event';
  const nextButtonRef = useRef<HTMLButtonElement>(null);

  const [events, setEvents] = useState<EventNode[]>([])

    File event-calendar.island.tsx has 289 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import {createIslandWebComponent} from 'preact-island'
    import {useCallback, useEffect, useRef, useState} from "preact/compat";
    import {DrupalJsonApiParams} from "drupal-jsonapi-params";
    import styled from "styled-components";
    import Jsona from "jsona";

      Method form has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public function form(array $form, FormStateInterface $form_state) {
          $form = parent::form($form, $form_state);
      
          $citation_type = $this->entity;
          $form['label'] = [
      Severity: Major
      Found in modules/stanford_publication/src/Form/CitationTypeForm.php - About 2 hrs to fix

        Method formElement has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
        
            // De-falt.
            $element = parent::formElement($items, $delta, $element, $form, $form_state);
            $element['#attached']['library'][] = 'core/drupal.states';

          Method getTypes has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public function getTypes(): array {
              $types = [];
          
              $types[] = new ObjectType([
                'name' => $this->getPluginId(),

            Method getTypes has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              public function getTypes(): array {
                $types = [];
            
                $types[] = new ObjectType([
                  'name' => $this->getPluginId(),

              Function EventCalendar has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring.
              Open

              const EventCalendar = () => {
                const apiUrl = (process.env?.LOCAL_DRUPAL ?? '') + '/jsonapi/node/stanford_event';
                const nextButtonRef = useRef<HTMLButtonElement>(null);
              
                const [events, setEvents] = useState<EventNode[]>([])

              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 getBibliography has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                public function getBibliography($style = self::APA): string {
              
                  $data = [
                    'id' => $this->id(),
                    'title' => $this->label(),
              Severity: Minor
              Found in modules/stanford_publication/src/Entity/Citation.php - About 1 hr to fix

                Method stanford_person_importer_post_update_8002 has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function stanford_person_importer_post_update_8002(&$sandbox) {
                  if (!\Drupal::database()
                    ->schema()
                    ->tableExists('migrate_map_su_stanford_person')) {
                    return;

                  Method baseFieldDefinitions has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
                      $fields = parent::baseFieldDefinitions($entity_type);
                  
                      $fields['title'] = BaseFieldDefinition::create('string')
                        ->setLabel(t('Title'))
                  Severity: Minor
                  Found in modules/stanford_publication/src/Entity/Citation.php - About 1 hr to fix

                    Method preSaveNode has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      protected function preSaveNode(NodeInterface $entity): void {
                        // Invalidate any search result cached so the updated/new content will be
                        // displayed for previously searched terms.
                        Cache::invalidateTags(['config:views.view.search']);
                    
                    
                    Severity: Minor
                    Found in src/EventSubscriber/EntityEventSubscriber.php - About 1 hr to fix

                      Method createParagraph has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        protected function createParagraph($bundle): EntityInterface {
                          // We've already created this paragraph type, just duplicated i.
                          if (isset($this->paragraphs[$bundle])) {
                            return $this->paragraphs[$bundle]->createDuplicate();
                          }

                        Method buildConfigurationForm has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
                            $form = parent::buildConfigurationForm($form, $form_state);
                        
                            // Extra CSS classes.
                            $form['extra_classes'] = [
                        Severity: Minor
                        Found in modules/jumpstart_ui/src/Layouts/JumpstartUiLayouts.php - About 1 hr to fix

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

                              attach: function attach(context, settings) {
                          
                                if (settings?.stanfordNews?.hideSocial) {
                                  return;
                                }
                          Severity: Minor
                          Found in modules/stanford_news/lib/js/news-node.js - About 1 hr to fix

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

                              public function toolbar() {
                                $notification_list = $this->getToolbarTrayItems($this->getUserNotifications());
                            
                                $items['notifications'] = [
                                  '#type' => 'toolbar_item',
                            Severity: Minor
                            Found in modules/stanford_notifications/src/NotificationService.php - About 1 hr to fix

                              Method insertOrgData has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                protected function insertOrgData(array $org_data, TermInterface $parent = NULL): void {
                                  if (!isset($org_data['orgCodes'])) {
                                    return;
                                  }
                              
                              

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

                                  public function blockForm($form, FormStateInterface $form_state) {
                                    $form = parent::blockForm($form, $form_state);
                                    $config = $this->getConfiguration();
                                
                                    $form['heading_text'] = [
                                Severity: Minor
                                Found in modules/jumpstart_ui/src/Plugin/Block/PageHeadingBlock.php - About 1 hr to fix

                                  Method getRomanNumeral has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    protected function getRomanNumeral(int $num): string {
                                      $map = [
                                        'M' => 1000,
                                        'CM' => 900,
                                        'D' => 500,

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

                                      protected function createParagraph($bundle): EntityInterface {
                                        // We've already created this paragraph type, just duplicated i.
                                        if (isset($this->paragraphs[$bundle])) {
                                          return $this->paragraphs[$bundle]->createDuplicate();
                                        }
                                    Severity: Minor
                                    Found in modules/stanford_profile_drush/src/Commands/StanfordProfileCommands.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 setMainMenuOverrides has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
                                    Open

                                      protected function setMainMenuOverrides(array $names, array &$overrides) {
                                        foreach ($names as $name) {
                                          if (str_starts_with($name, 'block.block.')) {
                                            $block_plugin = $this->configFactory->getEditable($name)
                                              ->getOriginal('plugin', FALSE);
                                    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