CRBT-Team/Purplet

View on GitHub

Showing 129 of 129 total issues

Similar blocks of code found in 10 locations. Consider refactoring.
Open

export function formatGuildIconURL(guildId: string, guildIcon: string, opts?: ImageURLOptions) {
  return formatImageURL(`/icons/${guildId}/${guildIcon}`, opts);
}
Severity: Major
Found in packages/utils/src/format/cdn.ts and 9 other locations - About 40 mins to fix
packages/utils/src/format/cdn.ts on lines 46..48
packages/utils/src/format/cdn.ts on lines 50..56
packages/utils/src/format/cdn.ts on lines 58..60
packages/utils/src/format/cdn.ts on lines 76..78
packages/utils/src/format/cdn.ts on lines 89..95
packages/utils/src/format/cdn.ts on lines 97..103
packages/utils/src/format/cdn.ts on lines 105..111
packages/utils/src/format/cdn.ts on lines 143..145
packages/utils/src/format/cdn.ts on lines 147..153

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 49.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 10 locations. Consider refactoring.
Open

export function formatGuildBannerURL(guildId: string, guildBanner: string, opts?: ImageURLOptions) {
  return formatImageURL(`/banners/${guildId}/${guildBanner}`, opts);
}
Severity: Major
Found in packages/utils/src/format/cdn.ts and 9 other locations - About 40 mins to fix
packages/utils/src/format/cdn.ts on lines 42..44
packages/utils/src/format/cdn.ts on lines 46..48
packages/utils/src/format/cdn.ts on lines 50..56
packages/utils/src/format/cdn.ts on lines 76..78
packages/utils/src/format/cdn.ts on lines 89..95
packages/utils/src/format/cdn.ts on lines 97..103
packages/utils/src/format/cdn.ts on lines 105..111
packages/utils/src/format/cdn.ts on lines 143..145
packages/utils/src/format/cdn.ts on lines 147..153

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 49.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

cli.command(
  'sync',
  'generate development-related files',
  args => args.positional(...rootPositional),
  args => start({ start: () => sync(args) })
Severity: Minor
Found in packages/purplet/src/cli/_cli.ts and 1 other location - About 40 mins to fix
packages/purplet/src/cli/_cli.ts on lines 90..95

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 49.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 10 locations. Consider refactoring.
Open

export function formatGuildSplashURL(guildId: string, guildSplash: string, opts?: ImageURLOptions) {
  return formatImageURL(`/splashes/${guildId}/${guildSplash}`, opts);
}
Severity: Major
Found in packages/utils/src/format/cdn.ts and 9 other locations - About 40 mins to fix
packages/utils/src/format/cdn.ts on lines 42..44
packages/utils/src/format/cdn.ts on lines 50..56
packages/utils/src/format/cdn.ts on lines 58..60
packages/utils/src/format/cdn.ts on lines 76..78
packages/utils/src/format/cdn.ts on lines 89..95
packages/utils/src/format/cdn.ts on lines 97..103
packages/utils/src/format/cdn.ts on lines 105..111
packages/utils/src/format/cdn.ts on lines 143..145
packages/utils/src/format/cdn.ts on lines 147..153

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 49.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

cli.command(
  'build',
  'build a production gateway client',
  args => args.positional(...rootPositional),
  args => start({ start: () => buildGateway(args) })
Severity: Minor
Found in packages/purplet/src/cli/_cli.ts and 1 other location - About 40 mins to fix
packages/purplet/src/cli/_cli.ts on lines 127..132

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 49.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    export interface StageChannel<Data extends APIVoiceChannel = APIVoiceChannel>
      extends GuildChannelBase<Data> {
      fetch(): Promise<StageChannel>;
    }
    Severity: Minor
    Found in packages/purplet/src/structures/channel/guild-stage.ts and 1 other location - About 35 mins to fix
    packages/purplet/src/structures/channel/guild-voice.ts on lines 13..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 47.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      get subcommandName() {
        return this.options.find(x => x.type === ApplicationCommandOptionType.Subcommand)?.name ?? null;
      }
    Severity: Minor
    Found in packages/purplet/src/structures/interaction/autocomplete.ts and 1 other location - About 35 mins to fix
    packages/purplet/src/structures/interaction/autocomplete.ts on lines 34..38

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 47.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    export interface VoiceChannel<Data extends APIVoiceChannel = APIVoiceChannel>
      extends GuildChannelBase<Data> {
      fetch(): Promise<VoiceChannel>;
    }
    Severity: Minor
    Found in packages/purplet/src/structures/channel/guild-voice.ts and 1 other location - About 35 mins to fix
    packages/purplet/src/structures/channel/guild-stage.ts on lines 13..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 47.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      get subcommandGroupName() {
        return (
          this.options.find(x => x.type === ApplicationCommandOptionType.SubcommandGroup)?.name ?? null
        );
      }
    Severity: Minor
    Found in packages/purplet/src/structures/interaction/autocomplete.ts and 1 other location - About 35 mins to fix
    packages/purplet/src/structures/interaction/autocomplete.ts on lines 30..32

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 47.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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 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 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 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 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 $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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    function isStreamable(data: BlobResolvable): data is Streamable {
      return typeof (data as Streamable).stream === 'function';
    }
    Severity: Minor
    Found in packages/utils/src/blob.ts and 1 other location - About 35 mins to fix
    packages/utils/src/blob.ts on lines 19..21

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 46.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    function isArrayBufferable(data: BlobResolvable): data is ArrayBufferable {
      return typeof (data as ArrayBufferable).arrayBuffer === 'function';
    }
    Severity: Minor
    Found in packages/utils/src/blob.ts and 1 other location - About 35 mins to fix
    packages/utils/src/blob.ts on lines 23..25

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 46.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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;
      Severity: Major
      Found in packages/gateway/src/Gateway.ts - About 30 mins to fix
        Severity
        Category
        Status
        Source
        Language