src/DataSource.ts
File DataSource.ts
has 730 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import _ from 'lodash';
import Keyv from 'keyv';
import {
DataQueryRequest,
Function query
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
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
Open
export class DataSource extends DataSourceApi<K6CloudQuery, K6CloudDataSourceOptions> {
url?: string;
cache?: Keyv;
constructor(instanceSettings: DataSourceInstanceSettings<K6CloudDataSourceOptions>) {
Avoid deeply nested control flow statements. Open
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
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
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
Open
return [];