doitintl/bigquery-grafana

View on GitHub
pkg/plugin.go

Summary

Maintainability
C
1 day
Test Coverage

Method BigQueryDatasource.query has a Cognitive Complexity of 49 (exceeds 20 allowed). Consider refactoring.
Open

func (td *BigQueryDatasource) query(ctx context.Context, query backend.DataQuery, req *backend.QueryDataRequest) backend.DataResponse {
    response := backend.DataResponse{}

    // Unmarshal the json into our queryModel
    var queryModel QueryModel
Severity: Minor
Found in pkg/plugin.go - About 5 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

Method BigQueryDatasource.executeQuery has 16 return statements (exceeds 4 allowed).
Open

func (td *BigQueryDatasource) executeQuery(ctx context.Context, queryModel QueryModel, originalQuery backend.DataQuery, req *backend.QueryDataRequest) (*BigQueryResult, error) {
    if !queryModel.RawQuery {
        return nil, errors.New("alerting queries only support raw sql")
    }

Severity: Major
Found in pkg/plugin.go - About 1 hr to fix

    Method BigQueryDatasource.executeQuery has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
    Open

    func (td *BigQueryDatasource) executeQuery(ctx context.Context, queryModel QueryModel, originalQuery backend.DataQuery, req *backend.QueryDataRequest) (*BigQueryResult, error) {
        if !queryModel.RawQuery {
            return nil, errors.New("alerting queries only support raw sql")
        }
    
    
    Severity: Minor
    Found in pkg/plugin.go - 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

    Method BigQueryDatasource.query has 9 return statements (exceeds 4 allowed).
    Open

    func (td *BigQueryDatasource) query(ctx context.Context, query backend.DataQuery, req *backend.QueryDataRequest) backend.DataResponse {
        response := backend.DataResponse{}
    
        // Unmarshal the json into our queryModel
        var queryModel QueryModel
    Severity: Major
    Found in pkg/plugin.go - About 55 mins to fix

      There are no issues that match your filters.

      Category
      Status