CRBT-Team/Purplet

View on GitHub

Showing 129 of 129 total issues

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

  static matches(raw: APIInteraction): raw is APIChatInputApplicationCommandInteraction {
    return CommandInteraction.matches(raw) && raw.data.type === ApplicationCommandType.ChatInput;
  }
packages/purplet/src/structures/interaction/command-message.ts on lines 17..19
packages/purplet/src/structures/interaction/command-user.ts on lines 17..19
packages/purplet/src/structures/interaction/component-button.ts on lines 12..14
packages/purplet/src/structures/interaction/component-select.ts on lines 16..20

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 60.

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 5 locations. Consider refactoring.
Open

  static matches(raw: APIInteraction): raw is APIMessageApplicationCommandInteraction {
    return CommandInteraction.matches(raw) && raw.data.type === ApplicationCommandType.Message;
  }
packages/purplet/src/structures/interaction/command-slash.ts on lines 16..18
packages/purplet/src/structures/interaction/command-user.ts on lines 17..19
packages/purplet/src/structures/interaction/component-button.ts on lines 12..14
packages/purplet/src/structures/interaction/component-select.ts on lines 16..20

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 60.

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 createViteConfig has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function createViteConfig(config: ResolvedConfig, mode: 'development' | 'production') {
  const userViteConfig = await (typeof config.vite === 'function' ? config.vite() : config.vite);

  const alias: Record<string, string> = {};

Severity: Minor
Found in packages/purplet/src/config/vite.ts - About 1 hr to fix

    Function runHook has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function runHook<Data, Type extends HookType>(
      features: FeatureArrayResolvable,
      hook: Hook<Data, Type>,
      extraArg?: Data | MergeFunction<Data, unknown>
    ) {
    Severity: Minor
    Found in packages/purplet/src/lib/hook-run.ts - About 1 hr to fix

      Function $mentionCommand has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function $mentionCommand(params: MentionCommandData) {
        return $merge([
          $gatewayEvent('MESSAGE_CREATE', async apiMessage => {
            const message = new Message(apiMessage);
      
      
      Severity: Minor
      Found in packages/purplet/src/hooks/mention-command.ts - About 1 hr to fix

        Function onRawPacket has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private onRawPacket(buf: string | Uint8Array) {
            let raw: Uint8Array | string;
            if (this.inflate) {
              const l = buf.length;
              // TODO: use a single equals check instead of four separate ones.
        Severity: Minor
        Found in packages/gateway/src/Gateway.ts - About 1 hr to fix

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

          export function formatGuildMemberAvatarURL(
            guildId: string,
            userId: string,
            memberAvatar: string,
            opts?: ImageURLOptions
          Severity: Major
          Found in packages/utils/src/format/cdn.ts and 2 other locations - About 1 hr to fix
          packages/utils/src/format/cdn.ts on lines 113..123
          packages/utils/src/format/cdn.ts on lines 155..162

          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 58.

          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 3 locations. Consider refactoring.
          Open

          export function formatGuildMemberBannerURL(
            guildId: string,
            userId: string,
            bannerId: string,
            opts?: ImageURLOptions
          Severity: Major
          Found in packages/utils/src/format/cdn.ts and 2 other locations - About 1 hr to fix
          packages/utils/src/format/cdn.ts on lines 80..87
          packages/utils/src/format/cdn.ts on lines 113..123

          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 58.

          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 3 locations. Consider refactoring.
          Open

          export function formatAchievementIconURL(
            applicationId: string,
            achievementId: string,
            iconHash: string,
            opts?: ImageURLOptions
          Severity: Major
          Found in packages/utils/src/format/cdn.ts and 2 other locations - About 1 hr to fix
          packages/utils/src/format/cdn.ts on lines 80..87
          packages/utils/src/format/cdn.ts on lines 155..162

          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 58.

          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 sendIdentify has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private sendIdentify() {
              if (this.sessionId) {
                debug('sending resume, seq=%s', this.seq);
                this.send({
                  op: GatewayOpcodes.Resume,
          Severity: Minor
          Found in packages/gateway/src/Gateway.ts - About 1 hr to fix

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

              async delete<Output>(endpoint: string, options?: RequestOptions): Promise<Output> {
                return this.request(endpoint, { method: 'DELETE', ...options });
              }
            Severity: Major
            Found in packages/rest/src/Rest.ts and 2 other locations - About 1 hr to fix
            packages/rest/src/Rest.ts on lines 147..149
            packages/rest/src/Rest.ts on lines 151..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 57.

            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 3 locations. Consider refactoring.
            Open

              async put<Output>(endpoint: string, options?: RequestOptions): Promise<Output> {
                return this.request(endpoint, { method: 'PUT', ...options });
              }
            Severity: Major
            Found in packages/rest/src/Rest.ts and 2 other locations - About 1 hr to fix
            packages/rest/src/Rest.ts on lines 147..149
            packages/rest/src/Rest.ts on lines 155..157

            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 57.

            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 3 locations. Consider refactoring.
            Open

              async post<Output>(endpoint: string, options?: RequestOptions): Promise<Output> {
                return this.request(endpoint, { method: 'POST', ...options });
              }
            Severity: Major
            Found in packages/rest/src/Rest.ts and 2 other locations - About 1 hr to fix
            packages/rest/src/Rest.ts on lines 151..153
            packages/rest/src/Rest.ts on lines 155..157

            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 57.

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

              alias: validate<ResolvedConfig['alias']>(def.alias, (input, keypath) => {
                if (typeof input !== 'object' || !input) {
                  throw new Error(`${keypath} should be an object`);
                }
            
            
            Severity: Minor
            Found in packages/purplet/src/config/resolver.ts - About 1 hr 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

                  <TabItem value='js' label='JavaScript'>
                    <CodeBlock language='js' title='purplet.config.js'>
                      {jsSource.trim()}
                    </CodeBlock>
                  </TabItem>
            sites/purplet.js.org/src/components/DefaultConfigCodeBlock/index.tsx on lines 31..35

            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 56.

            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

                  <TabItem value='ts' label='TypeScript'>
                    <CodeBlock language='ts' title='purplet.config.ts'>
                      {tsSource.trim()}
                    </CodeBlock>
                  </TabItem>
            sites/purplet.js.org/src/components/DefaultConfigCodeBlock/index.tsx on lines 36..40

            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 56.

            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 dynamicVirtual has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function dynamicVirtual(name: string, entries: VirtualEntry[]): Plugin {
              const log = new Logger('build:dynamic', { debug: true });
              const PREFIX = `\0virtual:${name}:`;
              return {
                name: `purplet-${name}`,
            Severity: Minor
            Found in packages/purplet/src/build/rollup-plugin-dynamic-virtual.ts - About 1 hr to fix

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

                  test(`#${++i}`, () => {
                    expect(S.generic.encode('aaaaaaaaaaaaaaaaaa').length).toBe(20);
                  });
              Severity: Major
              Found in packages/serialize/src/serializers.test.ts and 1 other location - About 1 hr to fix
              packages/serialize/src/serializers.test.ts on lines 131..133

              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 55.

              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

                  test(`#${++i}`, () => {
                    expect(S.generic.encode('244905301059436545').length).toBe(9);
                  });
              Severity: Major
              Found in packages/serialize/src/serializers.test.ts and 1 other location - About 1 hr to fix
              packages/serialize/src/serializers.test.ts on lines 134..136

              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 55.

              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

                  const data = await rest.interactionResponse.getFollowupMessage({
                    applicationId: this.interaction.applicationId,
                    interactionToken: this.interaction.token,
                    messageId: this.raw.id,
                  });
              Severity: Major
              Found in packages/purplet/src/structures/message-interaction.ts and 1 other location - About 1 hr to fix
              packages/purplet/src/structures/message-interaction.ts on lines 41..45

              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 55.

              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

              Severity
              Category
              Status
              Source
              Language