doitintl/bigquery-grafana

View on GitHub

Showing 55 of 55 total issues

Function constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  constructor($scope, $injector, private templateSrv, private $q, private uiSegmentSrv) {
    super($scope, $injector);
    this.queryModel = new BigQueryQuery(this.target, templateSrv, this.panel.scopedVars);
    this.updateProjection();
    this.formats = [
Severity: Minor
Found in src/query_ctrl.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

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

      return _.map(selectParts, (part: any) => {
        return {
          datatype: part.datatype,
          params: part.params,
          type: part.def.type,
Severity: Minor
Found in src/query_ctrl.ts and 1 other location - About 35 mins to fix
src/query_ctrl.ts on lines 162..168

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

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

    this.target.group = _.map(this.groupParts, (part: any) => {
      return {
        datatype: part.datatype,
        params: part.params,
        type: part.def.type,
Severity: Minor
Found in src/query_ctrl.ts and 1 other location - About 35 mins to fix
src/query_ctrl.ts on lines 146..152

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

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 (this.current.jsonData.flatRateProject === undefined) {
      this.current.jsonData.flatRateProject = this.defaultFlatRateProject;
    }
Severity: Minor
Found in src/config_ctrl.ts and 1 other location - About 35 mins to fix
src/config_ctrl.ts on lines 32..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 46.

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 (this.current.jsonData.processingLocations === undefined) {
      this.current.jsonData.processingLocations = this.defaultProcessingLocation;
    }
Severity: Minor
Found in src/config_ctrl.ts and 1 other location - About 35 mins to fix
src/config_ctrl.ts on lines 29..31

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

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

Avoid too many return statements within this function.
Open

    return {
      rows,
      schema,
    };
Severity: Major
Found in src/datasource.ts - About 30 mins to fix

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

      private _handelWildCardTables(tables) {
        let sorted = new Map();
        let newTables = [];
        for (const t of tables) {
          const partitioned = t.text.indexOf('__partitioned');
    Severity: Minor
    Found in src/response_parser.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 setUpPartition has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      private setUpPartition(query, isPartitioned, partitionedField, options, hasMacro = false, convertToUTC = false) {
        partitionedField = partitionedField ? partitionedField : '_PARTITIONTIME';
        const hasTimeFilter = !!(BigQueryQuery.hasDateFilter(query.split(/where/gi)[1] || "") || hasMacro);
        if (isPartitioned && !hasTimeFilter) {
          const { from: { _d: fromD }, to: { _d: toD } } = options.range;
    Severity: Minor
    Found in src/datasource.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 getDefaultProject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      public async getDefaultProject() {
        try {
          if (this.authenticationType === 'gce' || !this.projectName) {
            const data = await this.getProjects();
            this.projectName = data[0].value;
    Severity: Minor
    Found in src/datasource.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 _updateAlias has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      private _updateAlias(q, options, shiftstr) {
        if (shiftstr !== undefined) {
          const index = shiftstr.search(Shifted);
          const shifted = shiftstr.substr(index, shiftstr.length);
          for (const al of options.targets[0].select[0]) {
    Severity: Minor
    Found in src/datasource.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 _getInterval has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      public static _getInterval(q, alias: boolean) {
        const interval: string[] = [];
        const res = alias
          ? q.match(/(\$__timeGroupAlias\(([\w._]+,)).*?(?=\))/g)
          : q.match(/(\$__timeGroup\(([\w_.]+,)).*?(?=\))/g);
    Severity: Minor
    Found in src/bigquery_query.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 _buildAggregate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      public _buildAggregate(aggregate, query) {
        if (aggregate) {
          const func = aggregate.params[0];
          switch (aggregate.type) {
            case 'aggregate':
    Severity: Minor
    Found in src/bigquery_query.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 _setupTimeShiftQuery has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      private static _setupTimeShiftQuery(query, options) {
        const index = query.format.indexOf('#');
        const copy = options.constructor();
        for (const attr in options) {
          if (options.hasOwnProperty(attr)) {
    Severity: Minor
    Found in src/datasource.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 tableChanged has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      public tableChanged() {
        this.target.sharded = false;
        this.target.partitioned = false;
        this.target.partitionedField = '';
        this.target.table = this.tableSegment.value;
    Severity: Minor
    Found in src/query_ctrl.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 addGroup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      public addGroup(partType: string, value: string) {
        this._setGroupParts(partType, value);
        // add aggregates when adding group by
        for (const selectParts of this.selectParts) {
          if (!selectParts.some(part => part.def.type === 'aggregate')) {
    Severity: Minor
    Found in src/query_ctrl.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