Showing 20 of 712 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'] = [
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[]>([])
- 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 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(),
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'))
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 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 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']);
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'] = [
Function attach
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
attach: function attach(context, settings) {
if (settings?.stanfordNews?.hideSocial) {
return;
}
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',
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'] = [
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();
}
- 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 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);
- 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"