Showing 18 of 590 total issues
Function App
has 127 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function App() {
const apiUrl = '/jsonapi/node/stanford_event';
const currentDate = new Date();
const [anchorEl, setAnchorEl] = useState(null);
Method form
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
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
Open
public function getTypes(): array {
$types = [];
$types[] = new ObjectType([
'name' => $this->getPluginId(),
Method getBibliography
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
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
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
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
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']);
Function getEvents
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function getEvents(url, startDate, endDate) {
const filters = {status: 1};
if (startDate !== undefined) {
filters.startDate = {
condition: {
Method buildConfigurationForm
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Open
attach: function attach(context, settings) {
if (settings?.stanfordNews?.hideSocial) {
return;
}
Method toolbar
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
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
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
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
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
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"