Showing 889 of 1,485 total issues
Function collectBuildInformation
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
function collectBuildInformation(): string {
let compatibleEditors = 0;
const incompatibleEditors = new Set<string>();
const thisVersion = LexicalEditor.version;
if (typeof window !== 'undefined') {
- 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 addOptionsFromString
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function addOptionsFromString(string $searchString): void
{
/** @var array<string, SearchOption[]> $terms */
$terms = [
'exacts' => [],
Method run
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function run()
{
// Create an editor user
$editorUser = User::factory()->create();
$editorRole = Role::getRole('editor');
Function removeList
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function removeList(editor: LexicalEditor): void {
editor.update(() => {
const selection = $getSelection();
if ($isRangeSelection(selection)) {
Function setRootElement
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
setRootElement(nextRootElement: null | HTMLElement): void {
const prevRootElement = this._rootElement;
if (nextRootElement !== prevRootElement) {
const classNames = getCachedClassNameArray(this._config.theme, 'root');
Function handleTableCellRangeEvents
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function handleTableCellRangeEvents(editor) {
/** @var {HTMLTableCellElement[]} * */
let selectedCells = [];
editor.on('TableSelectionChange', event => {
Function handleEmbedAlignmentChanges
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function handleEmbedAlignmentChanges(editor) {
function updateClassesForPreview(previewElem) {
const mediaTarget = previewElem.querySelector('iframe, video');
if (!mediaTarget) {
return;
Method isSortChangePermissible
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function isSortChangePermissible(BookSortMapItem $sortMapItem, BookChild $model, ?Entity $currentParent, ?Entity $newBook, ?Entity $newChapter): bool
{
// Stop if we can't see the current parent or new book.
if (!$currentParent || !$newBook) {
return false;
Function $getSelectionStyleValueForProperty
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function $getSelectionStyleValueForProperty(
selection: RangeSelection | TableSelection,
styleProperty: string,
defaultValue = '',
): string {
Function select
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
select(_anchorOffset?: number, _focusOffset?: number): RangeSelection {
errorOnReadOnly();
let anchorOffset = _anchorOffset;
let focusOffset = _focusOffset;
const selection = $getSelection();
Function handleMediaInsert
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function handleMediaInsert(data: DataTransfer, context: EditorUiContext): boolean {
const clipboard = new Clipboard(data);
let handled = false;
// Don't handle the event ourselves if no items exist of contains table-looking data
Function setupTestCase
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const setupTestCase = (
cb: (selection: RangeSelection, el: ElementNode) => void,
) => {
const editor = createTestEditor();
Function setupTestCase
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const setupTestCase = (
cb: (selection: RangeSelection, el: ElementNode) => void,
) => {
const editor = createTestEditor();
Function _syncChildFromLexical
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_syncChildFromLexical(
binding: Binding,
index: number,
key: NodeKey,
prevNodeMap: null | NodeMap,
Function setupTestCase
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const setupTestCase = (
cb: (selection: RangeSelection, el: ElementNode) => void,
) => {
const editor = createTestEditor();
Function $sliceSelectedTextNodeContent
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function $sliceSelectedTextNodeContent(
selection: BaseSelection,
textNode: TextNode,
): LexicalNode {
const anchorAndFocus = selection.getStartEndPoints();
Function replace
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
replace<N extends LexicalNode>(
replaceWithNode: N,
includeChildren?: boolean,
): N {
if ($isListItemNode(replaceWithNode)) {
Function setup
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const setup = async (
mode: 'start-of-paragraph' | 'mid-paragraph' | 'end-of-paragraph',
) => {
const {container, editor} = testEnv;
Function mergeAction
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const mergeAction = (() => {
const isSameEditor =
currentHistoryEntry === null || currentHistoryEntry.editor === editor;
const shouldPushHistory = tags.has('history-push');
const shouldMergeHistory =
Function $normalizeTextNode
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function $normalizeTextNode(textNode: TextNode): void {
let node = textNode;
if (node.__text === '' && node.isSimpleText() && !node.isUnmergeable()) {
node.remove();