bencevans/node-influx

View on GitHub

Showing 34 of 34 total issues

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

export function parseMeasurement(q: measurement): string {
  if (typeof q.measurement === "function") {
    return q.measurement(new Measurement()).toString();
  }

Severity: Major
Found in src/builder.ts and 1 other location - About 1 hr to fix
src/builder.ts on lines 425..431

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

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

export function parseWhere(q: where): string {
  if (typeof q.where === "function") {
    return q.where(new Expression()).toString();
  }

Severity: Major
Found in src/builder.ts and 1 other location - About 1 hr to fix
src/builder.ts on lines 417..423

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

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

  public value(value: any): this {
    switch (typeof value) {
      case "number":
        this._query.push(value.toString());
        return this;
Severity: Minor
Found in src/builder.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 constructor has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  constructor(options?: any) {
    // Figure out how to parse whatever we were passed in into a IClusterConfig.
    if (typeof options === "string") {
      // Plain URI => ISingleHostConfig
      options = parseOptionsUrl(options);
Severity: Minor
Found in src/index.ts - About 1 hr to fix

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

      public value(value: any): this {
        switch (typeof value) {
          case "number":
            this._query.push(value.toString());
            return this;
    Severity: Minor
    Found in src/builder.ts - About 1 hr to fix

      Function parseInner has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function parseInner(
        series: IResponseSeries[] = [],
        precision?: TimePrecision
      ): IResults<any> {
        const results: any = [];
      Severity: Minor
      Found in src/results.ts - About 1 hr to fix

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

                parseSingle<{
                  id: number;
                  database: string;
                  retention_policy: string;
                  shard_group: number;
        Severity: Major
        Found in src/index.ts and 1 other location - About 1 hr to fix
        src/index.ts on lines 1179..1188

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

        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

            Array<{
              id: number;
              database: string;
              retention_policy: string;
              shard_group: number;
        Severity: Major
        Found in src/index.ts and 1 other location - About 1 hr to fix
        src/index.ts on lines 1200..1209

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

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

        function groupMethod(this: any, matcher: Tags): Row[] {
          // We do a tiny bit of 'custom' deep equality checking here, taking
          // advantage of the fact that the tag keys are consistent across all
          // series results. This lets us match groupings much more efficiently,
          // ~6000x faster than the fastest vanilla equality checker (lodash)
        Severity: Minor
        Found in src/results.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

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

                  if (typ !== "number" && !isNumeric(String(value))) {
                    throw new Error(
                      `Expected numeric value for ${this._ref(
                        field
                      )}, but got '${value}'!`
        Severity: Minor
        Found in src/schema.ts and 1 other location - About 55 mins to fix
        src/schema.ts on lines 86..92

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

        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 (typ !== "number" && !isNumeric(String(value))) {
                    throw new Error(
                      `Expected numeric value for ${this._ref(
                        field
                      )}, but got '${value}'!`
        Severity: Minor
        Found in src/schema.ts and 1 other location - About 55 mins to fix
        src/schema.ts on lines 74..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 53.

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

          public stream(
            options: IPoolRequestOptions,
            callback: (err: Error, res: http.IncomingMessage) => void
          ): void {
            if (!this.hostIsAvailable()) {
        Severity: Minor
        Found in src/pool.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 this;
        Severity: Major
        Found in src/builder.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                    return this;
          Severity: Major
          Found in src/builder.ts - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language