src/components/Tune/Dialog.tsx
Function Dialog
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
Open
const Dialog = ({
ui,
config,
tune,
url,
- 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
File Dialog.tsx
has 325 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { QuestionCircleOutlined } from '@ant-design/icons';
import {
Config as ConfigType,
ConstantTypes,
Curve as CurveType,
Function generatePanelsComponents
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
panels.map((panel: RenderedPanel) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
if (panel.type === PanelTypes.FIELDS && panel.fields.length === 0) {
return null;
}
Function panels
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const panels = Object.keys(resolvedDialogs).map((dialogName: string): RenderedPanel => {
const currentDialog: DialogType | CurveType | TableType = resolvedDialogs[dialogName];
let type = PanelTypes.CURVE;
let fields: FieldType[] = [];
Function resolveDialogs
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const resolveDialogs = (source: DialogsType, dialogName: string) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!source[dialogName]) {
return;
}
Avoid too many return
statements within this function. Open
Open
return (
<div ref={containerRef} className="large-container">
{renderHelp(dialogConfig.help)}
<Form labelCol={{ span: 10 }} wrapperCol={{ span: 10 }}>
<Row gutter={20}>{panelsComponents}</Row>