taskrabbit/elasticsearch-dump

View on GitHub

Showing 77 of 77 total issues

Function scrollResultSet has 116 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const scrollResultSet = (self, callback, loadedHits, response) => {
  let body

  if (loadedHits && loadedHits.length > 0) {
    // are we skipping and we have hits?
Severity: Major
Found in lib/transports/__es__/_helpers.js - About 4 hrs to fix

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

          aws4signer(esRequest, this.parent).then(() => {
            this.baseRequest(esRequest, (err, response) => {
              this.gotPolicies = true
              const payload = []
              err = this.handleError(err, response)
    Severity: Major
    Found in lib/transports/__es__/_policy.js and 1 other location - About 4 hrs to fix
    lib/transports/__es__/_alias.js on lines 15..26

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

    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

          aws4signer(esRequest, this.parent).then(() => {
            this.baseRequest(esRequest, (err, response) => {
              this.gotAliases = true
              const payload = []
              err = this.handleError(err, response)
    Severity: Major
    Found in lib/transports/__es__/_alias.js and 1 other location - About 4 hrs to fix
    lib/transports/__es__/_policy.js on lines 14..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 126.

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

    const aws4signer = async (esRequest, parent) => {
      // Consider deprecating - insecure to use on command line and credentials can be found by default at ~/.aws/credentials or as environment variables
      const useAwsCredentials = ((typeof parent.options.awsAccessKeyId === 'string') && (typeof parent.options.awsSecretAccessKey === 'string'))
      // Consider deprecating - can be achieved with awsChain and setting AWS_PROFILE and AWS_CONFIG_FILE environment variables as needed
      const useAwsProfile = (typeof parent.options.awsIniFileProfile === 'string')
    Severity: Minor
    Found in lib/aws4signer.js - About 3 hrs 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 setAnalyzer has 91 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      setAnalyzer (data, limit, offset, callback) {
        const updateAnalyzer = (err, response) => {
          if (err) { return callback(err) }
    
          try {
    Severity: Major
    Found in lib/transports/__es__/_analyzer.js - About 3 hrs to fix

      Function parse has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

        parse (argv, defaults, parseJSONOpts = false) {
          // parse passed options & use defaults otherwise
          for (const i in defaults) {
            this.options[i] = argv[i] || defaults[i]
      
      
      Severity: Minor
      Found in lib/argv.js - About 3 hrs 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 setMapping has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        setMapping (data, limit, offset, callback) {
          if (this.haveSetMapping === true || data.length === 0) {
            callback(null, 0)
          } else {
            const esRequest = {
      Severity: Major
      Found in lib/transports/__es__/_mapping.js - About 3 hrs to fix

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

              aws4signer(esRequest, this.parent).then(() => {
                this.baseRequest(esRequest, (err, response) => {
                  err = this.handleError(err, response)
                  if (err) {
                    return cb(err, [])
        Severity: Major
        Found in lib/transports/__es__/_template.js and 2 other locations - About 3 hrs to fix
        lib/transports/__es__/_policy.js on lines 48..57
        lib/transports/__es__/_script.js on lines 70..79

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

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

              aws4signer(esRequest, this.parent).then(() => {
                this.baseRequest(esRequest, (err, response) => {
                  err = this.handleError(err, response)
                  if (err) {
                    return cb(err, [])
        Severity: Major
        Found in lib/transports/__es__/_script.js and 2 other locations - About 3 hrs to fix
        lib/transports/__es__/_policy.js on lines 48..57
        lib/transports/__es__/_template.js on lines 103..112

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

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

              aws4signer(esRequest, this.parent).then(() => {
                this.baseRequest(esRequest, (err, response) => {
                  err = this.handleError(err, response)
                  if (err) {
                    return cb(err, [])
        Severity: Major
        Found in lib/transports/__es__/_policy.js and 2 other locations - About 3 hrs to fix
        lib/transports/__es__/_script.js on lines 70..79
        lib/transports/__es__/_template.js on lines 103..112

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

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

          setData (data, limit, offset, callback) {
            if (data.length === 0) { return callback(null, 0) }
        
            let writes = 0
        
        
        Severity: Major
        Found in lib/transports/__es__/_data.js - About 2 hrs to fix

          Function setAnalyzer has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

            setAnalyzer (data, limit, offset, callback) {
              const updateAnalyzer = (err, response) => {
                if (err) { return callback(err) }
          
                try {
          Severity: Minor
          Found in lib/transports/__es__/_analyzer.js - About 2 hrs 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 scrollResultSet has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          const scrollResultSet = (self, callback, loadedHits, response) => {
            let body
          
            if (loadedHits && loadedHits.length > 0) {
              // are we skipping and we have hits?
          Severity: Minor
          Found in lib/transports/__es__/_helpers.js - About 2 hrs 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 set has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

            set (data, limit, offset, callback) {
              const error = null
              let lineCounter = 0
          
              if (!this.stream) {
          Severity: Minor
          Found in lib/transports/file.js - About 2 hrs 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 updateAnalyzer has 62 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              const updateAnalyzer = (err, response) => {
                if (err) { return callback(err) }
          
                try {
                  data = jsonParser.parse(data[0])
          Severity: Major
          Found in lib/transports/__es__/_analyzer.js - About 2 hrs to fix

            Function anonymize has 60 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function anonymize (thing, options = {}) {
              if (
                thing === null ||
                thing instanceof Date
              ) {
            Severity: Major
            Found in transforms/anonymize.js - About 2 hrs to fix

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

                    } else if (this.shouldSplit) {
                      this.streamSplitter.end()
                    } else {
                      this.stream.on('close', () => {
                        delete this.stream
              Severity: Major
              Found in lib/transports/file.js and 1 other location - About 2 hrs to fix
              lib/transports/csv.js on lines 162..171

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

              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 (this.shouldSplit) {
                      this.streamSplitter.end()
                    } else {
                      this.stream.on('close', () => {
                        delete this.stream
              Severity: Major
              Found in lib/transports/csv.js and 1 other location - About 2 hrs to fix
              lib/transports/file.js on lines 71..80

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

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

                async getData (limit, offset, callback) {
                  let searchRequest, uri
                  let searchBodyTmp
              
                  if (this.parent.options.searchWithTemplate) {
              Severity: Major
              Found in lib/transports/__es__/_data.js - About 2 hrs to fix

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

                      } else if (type === 'component_template' || type === 'index_template') {
                        if (semver.gte(this.ESFullversion, '7.8.0')) {
                          this.featureFlag = true
                          this.getTemplates(limit, offset, callback)
                        } else {
                Severity: Major
                Found in lib/transports/elasticsearch.js and 1 other location - About 2 hrs to fix
                lib/transports/elasticsearch.js on lines 103..118

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

                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