forattini-dev/s3db.js

View on GitHub

Showing 60 of 60 total issues

Function main has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function main() {
  const s3db = new S3db({
    uri: ENV.CONNECTION_STRING,
    passphrase: ENV.PASSPRHASE,
    parallelism: ENV.PARALLELISM,
Severity: Minor
Found in examples/4-read-stream-to-zip.js - About 1 hr to fix

    Function getItems has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async getItems({
        continuationToken = null,
      }: {
        continuationToken?: string | null;
      } = {}) {
    Severity: Minor
    Found in src/stream/resource-ids-read-stream.class.ts - About 1 hr to fix

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

        constructor({
          s3Client,
          compressData = true,
          serializer = Serializers.json,
        }: {
      Severity: Major
      Found in src/cache/s3-cache.class.ts and 1 other location - About 1 hr to fix
      src/cache/s3-resource-cache.class.ts on lines 8..24

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

        constructor({
          resource,
          compressData = true,
          serializer = Serializers.json,
        }: {
      Severity: Major
      Found in src/cache/s3-resource-cache.class.ts and 1 other location - About 1 hr to fix
      src/cache/s3-cache.class.ts on lines 17..34

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

        async getContinuationTokenAfterOffset({
          prefix,
          offset = 1000,
        }: {
          prefix?: string;
      Severity: Minor
      Found in src/s3-client.class.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 getKeysPage has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async getKeysPage({
          prefix,
          offset = 0,
          amount = 100,
        }: {
      Severity: Minor
      Found in src/s3-client.class.ts - About 1 hr to fix

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

          async update(id: any, attributes: any) {
            const obj = await this.get(id);
        
            let attrs1 = flatten(attributes, { safe: true });
            let attrs2 = flatten(obj, { safe: true });
        Severity: Minor
        Found in src/s3-resource.class.ts - About 1 hr to fix

          Function studyOptions has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            studyOptions() {
              if (!this.options.afterUnmap) this.options.beforeMap = {};
              if (!this.options.afterUnmap) this.options.afterUnmap = {};
          
              const schema: any = flatten(this.schema, { safe: true });
          Severity: Minor
          Found in src/s3-resource.class.ts - About 1 hr to fix

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

                if (!isValid) {
                  return Promise.reject(
                    new S3dbInvalidResource({
                      bucket: this.s3Client.bucket,
                      resourceName: this.name,
            Severity: Major
            Found in src/s3-resource.class.ts and 1 other location - About 1 hr to fix
            src/s3-resource.class.ts on lines 227..236

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

              if (!s3db.resources.leads) {
                await s3db.createResource({
                  name: "leads",
                  attributes: {
                    name: "string",
            Severity: Major
            Found in examples/1-bulk-insert.js and 1 other location - About 1 hr to fix
            examples/5-write-stream.js on lines 16..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 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 2 locations. Consider refactoring.
            Open

              if (!s3db.resources.copyLeads) {
                await s3db.createResource({
                  name: "copy-leads",
                  attributes: {
                    name: "string",
            Severity: Major
            Found in examples/5-write-stream.js and 1 other location - About 1 hr to fix
            examples/1-bulk-insert.js on lines 33..42

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

                if (!isValid) {
                  return Promise.reject(
                    new S3dbInvalidResource({
                      bucket: this.s3Client.bucket,
                      resourceName: this.name,
            Severity: Major
            Found in src/s3-resource.class.ts and 1 other location - About 1 hr to fix
            src/s3-resource.class.ts on lines 299..308

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

              unmap(data: any) {
                const obj = Object.entries(data).reduce((acc: any, [key, value]) => {
                  acc[this.reversedMapObj[key]] = value;
                  return acc;
                }, {});
            Severity: Minor
            Found in src/s3-resource.class.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 insert has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async insert(attributes: any) {
                let { id, ...attrs }: { id: any; attrs: any } = flatten(attributes, {
                  safe: true,
                });
            
            
            Severity: Minor
            Found in src/s3-resource.class.ts - About 1 hr to fix

              Function deleteObjects has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async deleteObjects(keys: string[]) {
                  const packages = chunk(keys, 1000);
              
                  const { results, errors } = await PromisePool.for(packages)
                    .withConcurrency(this.parallelism)
              Severity: Minor
              Found in src/s3-client.class.ts - About 1 hr to fix

                Function getContinuationTokenAfterOffset has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async getContinuationTokenAfterOffset({
                    prefix,
                    offset = 1000,
                  }: {
                    prefix?: string;
                Severity: Minor
                Found in src/s3-client.class.ts - About 1 hr to fix

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

                        if (error instanceof Error) {
                          if (error.name === "NoSuchKey") {
                            return Promise.reject(
                              new ClientNoSuchKey({ bucket: this.bucket, key })
                            );
                  Severity: Major
                  Found in src/s3-client.class.ts and 1 other location - About 1 hr to fix
                  src/s3-client.class.ts on lines 75..81

                  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

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

                        if (error instanceof Error) {
                          if (error.name === "NoSuchKey") {
                            return Promise.reject(
                              new ClientNoSuchKey({ bucket: this.bucket, key })
                            );
                  Severity: Major
                  Found in src/s3-client.class.ts and 1 other location - About 1 hr to fix
                  src/s3-client.class.ts on lines 185..191

                  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 _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
                      Severity
                      Category
                      Status
                      Source
                      Language