CRBT-Team/Purplet

View on GitHub

Showing 65 of 129 total issues

Function resolveCreateMessageData has 40 lines of code (exceeds 25 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 1 hr to fix

    Function toJSONValue has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    export function toJSONValue<T extends JSONValue>(
      o: JSONResolvable<T>,
      locale: string = process.env['LOCALE'] ?? 'unknown'
    ): T {
      if (Array.isArray(o)) {
    Severity: Minor
    Found in packages/utils/src/json.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

    Function toJSONValue has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    export function toJSONValue<T extends JSONValue>(
      o: JSONResolvable<T>,
      locale: string = process.env['LOCALE'] ?? 'unknown'
    ): T {
      if (Array.isArray(o)) {
    Severity: Minor
    Found in packages/purplet/src/utils/json.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

    Function onClose has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private onClose({ code }: CloseEvent) {
        if (code === 1000) {
          return;
        }
    
    
    Severity: Minor
    Found in packages/gateway/src/Gateway.ts - About 1 hr to fix

      Function $slashCommand has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function $slashCommand<T>(options: SlashCommandData<T>) {
        const commandOptions = toJSONValue(options.options ?? []);
        const autocompleteHandlers = getOptionBuilderAutocompleteHandlers(options.options);
      
        return $merge([
      Severity: Minor
      Found in packages/purplet/src/hooks/command-slash.ts - About 1 hr to fix

        Function load has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              load(id) {
                const toInclude = id.split('+').filter(x => hookIDs.includes(x));
                if (toInclude.length === 0) {
                  return `export default []`;
                }
        Severity: Minor
        Found in packages/purplet/src/build/rollup-plugin-purplet-features.ts - About 1 hr to fix

          Function onRawPacket has a Cognitive Complexity of 12 (exceeds 5 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

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

          export async function deploy(options: DeployOptions) {
            Logger.info(`Preparing to ${options.delete ? 'delete' : 'deploy'} commands.`);
          
            const config = await loadConfig(options.root);
            const token = env.DISCORD_TOKEN;
          Severity: Minor
          Found in packages/purplet/src/cli/deploy.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

          Function prettierConfig has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export async function prettierConfig(config: ProjectConfig) {
            if (config.lang !== 'js') {
              // This config is based off of prettier-config-dave
              return {
                arrowParens: 'avoid',
          Severity: Minor
          Found in packages/create-purplet/src/options/prettier.ts - About 1 hr to fix

            Function deploy has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export async function deploy(options: DeployOptions) {
              Logger.info(`Preparing to ${options.delete ? 'delete' : 'deploy'} commands.`);
            
              const config = await loadConfig(options.root);
              const token = env.DISCORD_TOKEN;
            Severity: Minor
            Found in packages/purplet/src/cli/deploy.ts - About 1 hr to fix

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

              export function mergePresence(presences: PresenceHookData[]): GatewayPresenceUpdateData {
                const obj: GatewayPresenceUpdateData = {
                  afk: false,
                  activities: [],
                  since: null,
              Severity: Minor
              Found in packages/purplet/src/lib/hook-core-merge.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

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

              function $messageComponent<
                Context,
                CreateProps,
                ComponentType extends APIMessageActionRowComponent
              >(options: MessageComponentOptions<Context, CreateProps, ComponentType>) {
              Severity: Minor
              Found in packages/purplet/src/hooks/component.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

              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

                      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

                        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

                        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

                          Function runHook has a Cognitive Complexity of 9 (exceeds 5 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 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

                          Severity
                          Category
                          Status
                          Source
                          Language