forattini-dev/s3db.js

View on GitHub

Showing 30 of 60 total issues

Function _put has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async _put({ key, data }: { key: string; data: any }) {
    const lengthRaw = isString(data)
      ? data.length
      : JSON.stringify(data).length;

Severity: Minor
Found in src/cache/s3-cache.class.ts - About 1 hr to fix

    Function getAll has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async getAll() {
        if (this.s3Cache) {
          const cached = await this.s3Cache.get({ action: "getAll" });
          if (cached) return cached;
        }
    Severity: Minor
    Found in src/s3-resource.class.ts - About 1 hr to fix

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

        async getAll() {
          if (this.s3Cache) {
            const cached = await this.s3Cache.get({ action: "getAll" });
            if (cached) return cached;
          }
      Severity: Minor
      Found in src/s3-resource.class.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 map has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        map(data: any) {
          let obj: any = { ...data };
      
          for (const [attribute, actions] of Object.entries(this.options.beforeMap)) {
            for (const action of actions as string[]) {
      Severity: Minor
      Found in src/s3-resource.class.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 deleteObject has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        async deleteObject(key: string) {
          try {
            const options: any = {
              Bucket: this.bucket,
              Key: this.keyPrefix ? path.join(this.keyPrefix, key) : key,
      Severity: Minor
      Found in src/s3-client.class.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 headObject has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        async headObject(key: string) {
          try {
            const options: any = {
              Bucket: this.bucket,
              Key: this.keyPrefix ? path.join(this.keyPrefix, key) : key,
      Severity: Minor
      Found in src/s3-client.class.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 getKeysPage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        async getKeysPage({
          prefix,
          offset = 0,
          amount = 100,
        }: {
      Severity: Minor
      Found in src/s3-client.class.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 null;
      Severity: Major
      Found in src/cache/s3-cache.class.ts - About 30 mins to fix

        Function getObject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          async getObject(key: string) {
            try {
              const options = {
                Bucket: this.bucket,
                Key: path.join(this.keyPrefix, key),
        Severity: Minor
        Found in src/s3-client.class.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 _delete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          async _delete({ key }: { key: string }) {
            try {
              await this.s3Client.deleteObject(key);
            } catch (error) {
              if (error instanceof Error) {
        Severity: Minor
        Found in src/cache/s3-cache.class.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

        Severity
        Category
        Status
        Source
        Language