CRBT-Team/Purplet

View on GitHub

Showing 65 of 129 total issues

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

export async function toBlob(data: BlobResolvable): Promise<Blob> {
  if (data instanceof Blob) {
    return data;
  }
  if (isArrayBufferable(data)) {
Severity: Minor
Found in packages/utils/src/blob.ts - About 55 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 onPacket has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  private onPacket(packet: GatewayReceivePayload) {
    if (packet.s) {
      this.seq = packet.s;
    }

Severity: Minor
Found in packages/gateway/src/Gateway.ts - About 55 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 start has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  async start() {
    const spinner = new Spinner({
      text: this.firstRun ? 'Initializing development mode...' : 'Reloading...',
    });
    this.firstRun = false;
Severity: Minor
Found in packages/purplet/src/cli/dev.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 or has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function or<A, B>(a: BitSerializer<A>, b: BitSerializer<B>) {
  return new BitSerializer({
    read(buffer) {
      return buffer.read() ? a.read(buffer) : b.read(buffer);
    },
Severity: Minor
Found in packages/serialize/src/serializers.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 mergeCommands has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function mergeCommands(_list: ApplicationCommandResolvable[]) {
  /** I am sorry... */
  const list: any[] = _list;

  const groups = list.filter(x => 'isSlashCommandGroup' in x && !x.name.includes(' '));
Severity: Minor
Found in packages/purplet/src/lib/hook-core-merge.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 pluginFeatures has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function pluginFeatures({ config, featureScan }: FeaturesPluginOptions): Plugin {
  const hookIDs = Object.keys(featureScan);
  const featureScanValues = Object.values(featureScan);
  const fileNameList = unique(featureScanValues.map(x => Object.keys(x)).flat());
  const namesWithSymbols = fileNameList.map(filename => {
Severity: Minor
Found in packages/purplet/src/build/rollup-plugin-purplet-features.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 createConfig has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export async function createConfig(templatesRoot: string) {
  const config = {} as ProjectConfig;

  // Calculate initial directory based off of if this directory is 'empty' or not
  // Empty is a loose check that allows some stuff like `.git`
Severity: Minor
Found in packages/create-purplet/src/prompts.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

Consider simplifying this complex logical expression.
Open

    if (this.inflate) {
      const l = buf.length;
      // TODO: use a single equals check instead of four separate ones.
      const flush =
        l >= 4 &&
Severity: Major
Found in packages/gateway/src/Gateway.ts - About 40 mins to fix

    Function signedInt has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    function signedInt(bits: number) {
      const signBit = -1 << (bits - 1);
      return new BitSerializer({
        read(buffer) {
          const value = buffer.read(bits);
    Severity: Minor
    Found in packages/serialize/src/serializers.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

    Function loadConfig has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    export async function loadConfig(root: string) {
      const files = await readdir(root);
      const matched = searchPaths.filter(file => files.includes(file));
    
      if (matched.length === 0) {
    Severity: Minor
    Found in packages/purplet/src/config/index.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

    Function resolveEntrypoint has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    export async function resolveEntrypoint(entry: string): Promise<string | null> {
      if (await exists(entry)) {
        const stats = await stat(entry);
        if (stats.isDirectory()) {
          return resolveEntrypoint(path.join(entry, 'index'));
    Severity: Minor
    Found in packages/purplet/src/utils/fs.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

    Function buildPhase2 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    export async function buildPhase2({
      config,
      adapter,
      sharedRollupPlugins,
      featureScan,
    Severity: Minor
    Found in packages/purplet/src/build/phase2.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

    Function resolveCreateMessageData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    export function resolveCreateMessageData(input: CreateMessageData): CreateMessageResult {
      const data = toJSONValue(input as JSONResolvable<CreateMessageObject>);
    
      // String
      if (typeof data === 'string') {
    Severity: Minor
    Found in packages/purplet/src/structures/resolve/create-message.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

    Function $gatewayEvent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    export function $gatewayEvent<K extends keyof GatewayEventData>(
      eventName: K,
      handler: (data: GatewayEventData[K]) => void,
      options: GatewayEventHookData = {}
    ) {
    Severity: Minor
    Found in packages/purplet/src/hooks/gateway-event.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 new Blob([data]);
    Severity: Major
    Found in packages/utils/src/blob.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return;
      Severity: Major
      Found in packages/gateway/src/Gateway.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

          return o;
        Severity: Major
        Found in packages/utils/src/json.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return;
          Severity: Major
          Found in packages/gateway/src/Gateway.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

              return o;
            Severity: Major
            Found in packages/purplet/src/utils/json.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return;
              Severity: Major
              Found in packages/gateway/src/Gateway.ts - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language