Showing 438 of 1,408 total issues
Function processImpactDataWithScenario
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static processImpactDataWithScenario(
dataForImpactTableWithScenario: ImpactTableData[],
): ImpactTableData[] {
// Separate the data into different groups depending on whether data is from a scenario or not
const actualData: Map<string, ImpactTableData> = new Map();
- 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
Function getTrees
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
async getTrees(
supplierTreeOptions: GetSupplierTreeWithOptions,
): Promise<Supplier[]> {
if (supplierTreeOptions.withSourcingLocations) {
if (supplierTreeOptions.originIds) {
- 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
Function processDataForComparison
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static processDataForComparison(
impactTableData: ImpactTableData[],
): ActualVsScenarioImpactTableData[] {
// Separate the data into different maps depending on whether data is from a scenario or not
const actualData: Map<string, ActualVsScenarioImpactTableData> = new Map();
- 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
Function getFromArrayAndParsedString
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static getFromArrayAndParsedString<T>(
arrayProperty: string,
stringProperty?: string,
defaultValue?: T,
): (T | string)[] {
- 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
Function intercept
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
async intercept(
context: ExecutionContext,
next: CallHandler,
): Promise<Observable<any>> {
if (this.scenarioAcl.isUserAdmin()) {
- 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
Function createSourcingLocationDTOFromData
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private async createSourcingLocationDTOFromData(
sourcingLocationData: Record<string, any>,
sourcingLocationGroupId?: string,
): Promise<CreateSourcingLocationDto> {
const sourcingLocationDto: CreateSourcingLocationDto =
- 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
Function Ranking
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const Ranking: React.FC<RankingProps> = ({ ingredientId, onTradingFlowChange }) => {
const [currentTradingFlow, setCurrentTradingFlow] = useState<CountryTrade | null>(null);
const ingredient = useMemo<Ingredient>(
() => INGREDIENTS.find((i) => i.id === ingredientId) || INGREDIENTS[0],
[ingredientId],
- 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
Function Header
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const Header: React.FC = () => {
const [open, setOpen] = useState(false);
const { scrollDirection } = useScrollDirection();
const prevDirection = useRef<string | number>(0);
- 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 param;
Avoid too many return
statements within this function. Open
return true;
Function DataUploadError
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const DataUploadError: React.FC<DataUploadErrorProps> = ({ task }) => {
const [open, setOpen] = useState(true);
const updateTask = useUpdateTask();
const { data: profile, isLoading: profileIsLoading } = useProfile();
- 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
Function Input
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
({ className, error, icon, type = 'text', unit, showHint = true, ...inputProps }, ref) => (
<>
<div className={classnames('relative rounded-md shadow-sm', className)}>
{icon && (
<div className="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
- 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
Function setTooltipData
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
setTooltipData: (state, action: PayloadAction<TooltipData>) => {
const exists = !!state.tooltipData.find(({ id }) => action.payload.id === id);
// Remove tooltip is value is undefined but not zero
if (exists && !action.payload.value && action.payload.value !== 0) {
return {
- 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
Function AdminEditTargetModal
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const AdminEditTargetModal: React.FC<EditTargetModalProps> = ({ title, open, onDismiss }) => {
const { data, isLoading } = useSourcingRecordsYears();
const { data: targets } = useTargets();
const [selectedOption, setSelectedOption] = useState<Option<number>>(null);
- 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
Function nominatim_request
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def nominatim_request(params, request_type="search", pause=1, error_pause=60):
"""
Send a HTTP GET request to the Nominatim API and return JSON response.
Parameters
----------
- 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
Function open_clean
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def open_clean(file):
# Define the units available for conversion
units_to_tonnes = {"100 g/An": 100000, "100 mg/An": 1000000}
# Open the file
- 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
Function Pagination
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const Pagination: React.FC<PaginationProps> = ({
className,
currentPage,
isLoading = false,
onPageChange,
- 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
Function buildTags
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const buildTags = ({ title, titleTemplate, defaultTitle }: TitleTemplateProps) => {
const tagsToRender: React.ReactNode[] = [];
if (titleTemplate) {
defaults.titleTemplate = titleTemplate;
- 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
Function CustomTooltip
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const CustomTooltip: React.FC<CustomTooltipProps> = ({ payload }) => {
const { comparisonMode } = useAppSelector(scenarios);
const tooltipData = uniqBy(payload, 'stroke');
// We will assume that actual-data is the first item and the scenario is the second one
const baseValue = tooltipData[0]?.value;
- 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
Function AdminDataPage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const AdminDataPage: React.FC = () => {
const { push, query } = useRouter();
const [sorting, setSorting] = useState<SortingState>([]);
const { data: session } = useSession();
const { data: task } = useLasTask();
- 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"