File SyncCursors.ts
has 451 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
Function syncCursorPositions
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
export function syncCursorPositions(
binding: Binding,
provider: Provider,
): void {
const awarenessStates = Array.from(provider.awareness.getStates());
- 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 updateCursor
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
function updateCursor(
binding: Binding,
cursor: Cursor,
nextSelection: null | CursorSelection,
nodeMap: NodeMap,
Function updateCursor
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
function updateCursor(
binding: Binding,
cursor: Cursor,
nextSelection: null | CursorSelection,
nodeMap: NodeMap,
- 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 syncCursorPositions
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function syncCursorPositions(
binding: Binding,
provider: Provider,
): void {
const awarenessStates = Array.from(provider.awareness.getStates());
Function syncLexicalSelectionToYjs
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function syncLexicalSelectionToYjs(
binding: Binding,
provider: Provider,
prevSelection: null | BaseSelection,
nextSelection: null | BaseSelection,
Function createRelativePosition
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function createRelativePosition(
point: Point,
binding: Binding,
): null | RelativePosition {
const collabNodeMap = binding.collabNodeMap;
- 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 createRelativePosition
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createRelativePosition(
point: Point,
binding: Binding,
): null | RelativePosition {
const collabNodeMap = binding.collabNodeMap;
Function $syncLocalCursorPosition
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function $syncLocalCursorPosition(
binding: Binding,
provider: Provider,
): void {
const awareness = provider.awareness;
Function $syncLocalCursorPosition
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export function $syncLocalCursorPosition(
binding: Binding,
provider: Provider,
): void {
const awareness = provider.awareness;
- 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 syncLexicalSelectionToYjs
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export function syncLexicalSelectionToYjs(
binding: Binding,
provider: Provider,
prevSelection: null | BaseSelection,
nextSelection: null | BaseSelection,
- 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
Avoid deeply nested control flow statements. Open
if (anchorCollabNode !== null && focusCollabNode !== null) {
const anchorKey = anchorCollabNode.getKey();
const focusKey = focusCollabNode.getKey();
selection = cursor.selection;
Function createCursorSelection
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
cursor: Cursor,
anchorKey: NodeKey,
anchorOffset: number,
focusKey: NodeKey,
focusOffset: number,
Function $setPoint
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function $setPoint(point: Point, key: NodeKey, offset: number): void {
if (point.key !== key || point.offset !== offset) {
let anchorNode = $getNodeByKey(key);
if (
anchorNode !== null &&
- 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
Avoid too many return
statements within this function. Open
return;
Avoid too many return
statements within this function. Open
return;