bootstrapworld/codemirror-blocks

View on GitHub

Showing 132 of 132 total issues

Function Toggle Selection has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

"Toggle Selection": (env, e) => (dispatch, getState) => {
if (!env.isNodeEnv) {
return;
}
e.preventDefault();
Severity: Minor
Found in packages/codemirror-blocks/src/keymap.tsx - About 1 hr to fix

Function constructor has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

constructor(parent: ASTNode, child: ASTNode) {
this.parent = parent;
this.child = child;
for (const spec of parent.spec.childSpecs) {
if (spec instanceof List) {
Severity: Minor
Found in packages/codemirror-blocks/src/edits/fakeAstEdits.ts - About 1 hr to fix

Function ToggleEditor has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function ToggleEditor(props: ToggleEditorProps) {
const [editor, setEditor] = useState<CodeMirrorFacade | null>(null);
const blockMode = useSelector(selectors.isBlockModeEnabled);
const dispatch: AppDispatch = useDispatch();
const code = useSelector(selectors.getCode);
Severity: Minor
Found in packages/codemirror-blocks/src/ui/ToggleEditor.tsx - About 1 hr to fix

Function getNodeContainingBiased has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export function getNodeContainingBiased(cursor: Pos, ast: AST) {
function iter(nodes: Readonly<ASTNode[]>): ASTNode | null {
const node = nodes.find(
(node) =>
posWithinNodeBiased(cursor, node) || nodeCommentContaining(cursor, node)
Severity: Minor
Found in packages/codemirror-blocks/src/utils.ts - About 1 hr to fix

Function commitChanges has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

(
changes: ChangeObject[],
editor: ReadonlyCMBEditor,
isUndoOrRedo: boolean,
focusHint?: FocusHint,
Severity: Minor
Found in packages/codemirror-blocks/src/edits/commitChanges.ts - About 1 hr to fix

Function cloneNode has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export function cloneNode(oldNode: ASTNode): ASTNode {
const nodeLike = { type: oldNode.type, fields: {} as any };
for (const spec of oldNode.spec.childSpecs) {
if (spec instanceof Required) {
spec.setField(nodeLike, cloneNode(spec.getField(oldNode)));
Severity: Minor
Found in packages/codemirror-blocks/src/edits/fakeAstEdits.ts - About 1 hr to fix

Function Symbol.iterator has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

*[Symbol.iterator](): Iterator<number> {
for (const spec of this.nodeSpec.childSpecs) {
if (spec instanceof Value) {
yield hashObject(spec.getField(this.parent));
} else if (spec instanceof List) {
Severity: Minor
Found in packages/codemirror-blocks/src/nodeSpec.ts - About 1 hr to fix

Function editsToChange has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function editsToChange(
edits: readonly EditInterface[],
ast: AST,
text: ReadonlyRangedText
): ChangeObject[] {
Severity: Minor
Found in packages/codemirror-blocks/src/edits/performEdits.ts - About 1 hr to fix

Function fromConfig has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

static fromConfig(languageId: string, config: PrimitiveGroupConfig) {
const { name, primitives = [] } = config;
if (!name) {
throw new Error("No name specified for primitive group");
}
Severity: Minor
Found in packages/codemirror-blocks/src/parsers/primitives.ts - About 1 hr to fix

Function Edit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

Edit: (env, e) => (dispatch, getState) => {
if (!env.isNodeEnv) {
return;
}
if (env.normallyEditable) {
Severity: Minor
Found in packages/codemirror-blocks/src/keymap.tsx - About 1 hr to fix

Function Symbol.iterator has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

*[Symbol.iterator]() {
for (const spec of this.nodeSpec.childSpecs) {
if (spec instanceof Value) continue;
const field = spec.getField(this.parent);
if (field instanceof ASTNode) {
Severity: Minor
Found in packages/codemirror-blocks/src/nodeSpec.ts - About 55 mins to fix

Function Previous Block has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

"Previous Block": (env, e) => (dispatch, getState) => {
const state = getState();
const ast = selectors.getAST(state);
e.preventDefault();
if (env.isNodeEnv) {
Severity: Minor
Found in packages/codemirror-blocks/src/keymap.tsx - About 55 mins to fix

Function annotateNodes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function annotateNodes(
nodes: Readonly<ASTNode[]>
): Omit<ASTData, "languageId"> {
const nodeIdMap = new Map<string, ASTNode>();
const nodeNIdMap = new Map<number, ASTNode>();
Severity: Minor
Found in packages/codemirror-blocks/src/ast.ts - About 55 mins to fix

Function copy has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export function copy(nodes: ASTNode[], editWord?: string) {
const previouslyFocusedElement = document.activeElement;
if (nodes.length === 0) {
return;
}
Severity: Minor
Found in packages/codemirror-blocks/src/copypaste.ts - About 55 mins to fix

Function search has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

search: (cur, settings, editor, state, forward) => {
const ast = selectors.getAST(state);
const { collapsedList } = state;
let startingNode = getNodeContainingBiased(cur, ast);
if (!startingNode) {
Severity: Minor
Found in packages/codemirror-blocks/src/ui/searchers/ByBlock.tsx - About 55 mins to fix

Function constructor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

constructor(parent: ASTNode, fieldName: string, pos: Pos) {
this.parent = parent;
this.pos = pos;
// Find the spec that matches the supplied field name.
let spec: List | null = null;
Severity: Minor
Found in packages/codemirror-blocks/src/edits/fakeAstEdits.ts - About 55 mins to fix

Avoid deeply nested control flow statements.
Open

} else if (node instanceof structures.requireExpr) {
return new FunctionApp(
from,
to,
parseNode(node.stx),
Severity: Major
Found in packages/codemirror-blocks/src/languages/wescheme/WeschemeParser.js - About 45 mins to fix

    Function Next Block has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    "Next Block": (env, e) => (dispatch, getState) => {
    e.preventDefault();
    const ast = selectors.getAST(getState());
    if (env.isNodeEnv) {
    const next = env.fastSkip((node) => ast.getNodeAfter(node) || undefined);
    Severity: Minor
    Found in packages/codemirror-blocks/src/keymap.tsx - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

    } else if (node instanceof structures.requireExpr) {
    return FunctionApp(from, to, parseNode(node.stx), [parseNode(node.spec)], {
    ariaLabel: "require " + node.spec.val,
    comment: comment,
    });
    Severity: Major
    Found in packages/wescheme-blocks/src/parseNode.ts - About 45 mins to fix

      Function filter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      filter(search: string): PrimitiveGroup {
      if (!search) {
      return this;
      }
      const result = [];
      Severity: Minor
      Found in packages/codemirror-blocks/src/parsers/primitives.ts - About 45 mins to fix
      Severity
      Category
      Status
      Source
      Language