Showing 10 of 10 total issues
File DataSource.ts
has 730 lines of code (exceeds 250 allowed). Consider refactoring. Open
import _ from 'lodash';
import Keyv from 'keyv';
import {
DataQueryRequest,
File QueryEditor.tsx
has 387 lines of code (exceeds 250 allowed). Consider refactoring. Open
import _ from 'lodash';
import React, { PureComponent } from 'react';
import { Icon, InlineFormLabel } from '@grafana/ui';
import { QueryEditorProps, SelectableValue } from '@grafana/data';
Function query
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
async query(options: DataQueryRequest<K6CloudQuery>): Promise<DataQueryResponse> {
let data = { data: [] as MutableDataFrame[] };
for (const target of options.targets) {
if (target.hide) {
- Read upRead up
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
DataSource
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
export class DataSource extends DataSourceApi<K6CloudQuery, K6CloudDataSourceOptions> {
url?: string;
cache?: Keyv;
constructor(instanceSettings: DataSourceInstanceSettings<K6CloudDataSourceOptions>) {
QueryEditor
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
export class QueryEditor extends PureComponent<Props, QueryEditorState> {
url?: string;
lastTagId: number;
state: QueryEditorState = {
projectList: [],
Function getUnitFromMetric
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export const getUnitFromMetric = (metric: K6Metric, aggregation?: string) => {
switch (metric.type) {
case K6MetricType.COUNTER:
if (_.includes(['data_received', 'data_sent'], metric.name)) {
return aggregation === 'rps' ? 'bps' : 'bytes';
- Read upRead up
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 deeply nested control flow statements. Open
if (resolvedTestRunId) {
const thresholdsList = await this.getThresholdsForTestRun(resolvedTestRunId);
const fields = this.convertThresholdsToFields(thresholdsList);
data.data.push(
new MutableDataFrame({
Avoid deeply nested control flow statements. Open
} else if (qtype === K6QueryType.URLS) {
if (resolvedTestRunId) {
const urlsList = await this.getURLsForTestRun(resolvedTestRunId);
const fields = this.convertURLsToFields(urlsList);
data.data.push(
Function convertSeriesToFields
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
convertSeriesToFields(series: K6Series, metric: K6Metric, tags?: Map<string, string>, aggregation?: string) {
const timeValues = _.map(series.values, (d) => {
return dateTimeParse(d.timestamp).unix() * 1000;
});
const values = _.map(series.values, (d) => {
- Read upRead up
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 [];