ssube/textual-engine

View on GitHub

Showing 107 of 123 total issues

Avoid deeply nested control flow statements.
Open

            if (portal.link === PortalLinkage.BOTH) {
              // find existing portal
              const existingPortal = existingRoom.portals.find((it) => isDestPortal(portal, it));

              if (doesExist(existingPortal)) {
Severity: Major
Found in src/util/entity/EntityGenerator.ts - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                for (const item of actor.items) {
                  if (seen.has(item.meta.id) === false) {
                    seen.add(item.meta.id);
                    await this.script.invoke(item, SIGNAL_STEP, {
                      ...scope,
    Severity: Major
    Found in src/service/state/LocalState.ts - About 45 mins to fix

      Function makeTestRoom has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        id: string,
        name: string,
        template: string,
        actors: Array<Actor> = [],
        items: Array<Item> = [],
      Severity: Minor
      Found in test/entity.ts - About 45 mins to fix

        Function modifyActor has a Cognitive Complexity of 9 (exceeds 6 allowed). Consider refactoring.
        Open

          public async modifyActor(target: Actor, available: Array<Modifier<Actor>>): Promise<void> {
            const selected = this.selectModifiers(available);
        
            for (const mod of selected) {
              // target.source cannot be modified
        Severity: Minor
        Found in src/util/entity/EntityGenerator.ts - About 45 mins to fix

        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 SignalActorStep has a Cognitive Complexity of 9 (exceeds 6 allowed). Consider refactoring.
        Open

        export async function SignalActorStep(this: ScriptTarget, context: ScriptContext): Promise<void> {
          const actor = assertActor(this);
        
          const health = getKey(actor.stats, STAT_HEALTH, 0);
          if (health <= 0) {
        Severity: Minor
        Found in src/script/signal/actor/ActorStep.ts - About 45 mins to fix

        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 getVerbScripts has a Cognitive Complexity of 9 (exceeds 6 allowed). Consider refactoring.
        Open

        export function getVerbScripts(target: VerbTarget): ImmutableScriptMap {
          const scripts: ImmutableScriptMap = new Map();
        
          if (isActor(target.actor)) {
            mergeVerbScripts(scripts, target.actor.scripts);
        Severity: Minor
        Found in src/util/script/index.ts - About 45 mins to fix

        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 (seen.has(portal.meta.id) === false) {
                      seen.add(portal.meta.id);
                      await this.script.invoke(portal, SIGNAL_STEP, {
                        ...scope,
                        portal,
        Severity: Major
        Found in src/service/state/LocalState.ts - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      if (doesExist(existingPortal)) {
                        existingPortal.dest = room.meta.id;
                      } else {
                        // or create reverse link
                        const destPortal = await this.reversePortal(portal, room);
          Severity: Major
          Found in src/util/entity/EntityGenerator.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                        if (seen.has(item.meta.id) === false) {
                          seen.add(item.meta.id);
                          await this.script.invoke(item, SIGNAL_STEP, {
                            ...scope,
                            item,
            Severity: Major
            Found in src/service/state/LocalState.ts - About 45 mins to fix

              Function makeTestPortal has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              export function makeTestPortal(id: string, name: string, source: string, target: string, dest: string): Portal {
              Severity: Minor
              Found in test/entity.ts - About 35 mins to fix

                Function Shortcuts has a Cognitive Complexity of 8 (exceeds 6 allowed). Consider refactoring.
                Open

                export const Shortcuts = (props: ShortcutProps): JSX.Element => {
                  const { t } = useTranslation();
                  const [tab, setTab] = useState<ShortcutKeys>('actors');
                  const { isFocused: tabFocus } = useFocus();
                  const { isFocused: itemFocus } = useFocus();
                Severity: Minor
                Found in src/component/ink/Shortcuts.tsx - About 35 mins to fix

                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 groupOn has a Cognitive Complexity of 8 (exceeds 6 allowed). Consider refactoring.
                Open

                export function groupOn<TValue>(items: ReadonlyArray<TValue>, delimiters: Set<TValue>): Array<Array<TValue>> {
                  const groups = [];
                  const buffer = [];
                
                  for (const item of items) {
                Severity: Minor
                Found in src/util/collection/array.ts - About 35 mins to fix

                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 context.state.show(context.source, 'actor.verb.push.dest.room', { actor, command, portal, room: target });
                Severity: Major
                Found in src/script/verb/actor/ActorPush.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return context.state.show(context.source, 'actor.verb.push.dest.missing', { actor, command, portal });
                  Severity: Major
                  Found in src/script/verb/actor/ActorPush.ts - About 30 mins to fix

                    Function SignalActorLook has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring.
                    Open

                    export async function SignalActorLook(this: ScriptTarget, context: ScriptContext): Promise<void> {
                      const actor = assertActor(this);
                    
                      const health = getKey(actor.stats, STAT_HEALTH, 0);
                    
                    
                    Severity: Minor
                    Found in src/script/signal/actor/ActorLook.ts - About 25 mins to fix

                    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 equipItems has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring.
                    Open

                    export function equipItems(actor: Actor, items: StringMap): void {
                      for (const [slot, id] of items) {
                        if (actor.slots.has(slot)) {
                          const item = actor.items.find((it) => matchIdSegments(it.meta.id, id));
                          if (doesExist(item) && matchIdSegments(item.slot, slot)) {
                    Severity: Minor
                    Found in src/util/entity/index.ts - About 25 mins to fix

                    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 SignalBehaviorDraculaVanHelsing has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring.
                    Open

                    export async function SignalBehaviorDraculaVanHelsing(this: ScriptTarget, context: ScriptContext): Promise<void> {
                      const actor = assertActor(this);
                    
                      const room = mustExist(context.room);
                      const actors = await context.state.find({
                    Severity: Minor
                    Found in src/script/signal/behavior/dracula/BehaviorVanHelsing.ts - About 25 mins to fix

                    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 modifyItem has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring.
                    Open

                      public async modifyItem(target: Item, available: Array<Modifier<Item>>): Promise<void> {
                        const selected = this.selectModifiers(available);
                    
                        for (const mod of selected) {
                          if (doesExist(mod.meta)) {
                    Severity: Minor
                    Found in src/util/entity/EntityGenerator.ts - About 25 mins to fix

                    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 selectModifiers has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring.
                    Open

                      public selectModifiers<TBase>(mods: Array<Modifier<TBase>>): Array<Partial<BaseModifier<TBase>>> {
                        const excluded = new Set<string>();
                        const selected = [];
                    
                        for (const mod of mods) {
                    Severity: Minor
                    Found in src/util/entity/EntityGenerator.ts - About 25 mins to fix

                    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

                    TODO found
                    Open

                        // TODO: make assertions
                    Severity
                    Category
                    Status
                    Source
                    Language