Showing 438 of 1,408 total issues
Function getImpactMap
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async getImpactMap(
dto: GetImpactMapDto,
): Promise<{ impactMap: H3IndexValueData[]; quantiles: number[] }> {
const baseQueryExtend = (baseQuery: SelectQueryBuilder<any>): void => {
//Having a scenarioId present as an argument, will change the query to include
Function up
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
CREATE OR REPLACE FUNCTION get_h3_material_table_column(h3DataId uuid)
RETURNS TABLE (h3_table_name varchar, h3_column_name varchar) AS
$$
Function extendFindAllQuery
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async extendFindAllQuery(
query: SelectQueryBuilder<SourcingLocation>,
fetchSpecification: Record<string, unknown>,
): Promise<SelectQueryBuilder<SourcingLocation>> {
const sortingOrder: 'DESC' | 'ASC' | undefined =
Function getScenarioVsScenarioImpactMap
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async getScenarioVsScenarioImpactMap(
dto: GetScenarioVsScenarioImpactMapDto,
): Promise<{ impactMap: H3IndexValueData[]; quantiles: number[] }> {
const baseQueryExtend = (baseQuery: SelectQueryBuilder<any>): void => {
//Add selection criteria to also select both baseScenario and comparedScenario in the select statement
Function getAggregatedH3ByNameAndResolution
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async getAggregatedH3ByNameAndResolution(
h3TableName: string,
h3ColumnName: string,
resolution: number,
aggregationType: CONTEXTUAL_LAYER_AGG_TYPE,
Function activateIndicators
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async activateIndicators(
indicatorsFromSheet: CreateIndicatorDto[],
): Promise<Indicator[]> {
const nameCodesToActivateIndicatorsBy: string[] = indicatorsFromSheet
.filter((i: CreateIndicatorDto) => i.status === INDICATOR_STATUS.ACTIVE)
Function getScenarioVsScenarioImpactTable
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async getScenarioVsScenarioImpactTable(
dto: GetScenarioVsScenarioImpactTableDto,
fetchSpecification: FetchSpecification,
): Promise<ScenarioVsScenarioPaginatedImpactTable> {
const indicators: Indicator[] =
Function buildQuery
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
buildQuery(): Query {
if (this.dto?.supplierIds) {
this.queryBuilder.andWhere(
`${EUDRAlertsFields.supplierId} IN (:...supplierIds)`,
{
Function getContextualLayerH3
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async getContextualLayerH3(
contextualLayerId: string,
resolution?: number,
year?: number,
): Promise<{
Function getFlowLineAttributesByIndex
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function getFlowLineAttributesByIndex(
lineAttributes: FlowLinesLayerAttributes,
index: number,
): FlowLinesLayerAttributes {
const {
Function getColors
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function getColors(
diffMode: boolean,
schemeKey: string | undefined,
darkMode: boolean,
fadeEnabled: boolean,
Function CreateInterventionPage
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const CreateInterventionPage: React.FC = () => {
const { query } = useRouter();
const createIntervention = useCreateNewIntervention({
onSuccess: (_data, variables) => {
toast.success(`Intervention was created successfully`);
Function ChartPage
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const ChartPage: NextPageWithLayout = () => {
const dispatch = useAppDispatch();
const [syncedIndicators] = useSyncIndicators();
const { data, isLoading } = useIndicators(undefined, {
Function addReplacingElementsToIntervention
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async addReplacingElementsToIntervention(
newIntervention: ScenarioIntervention,
newSourcingLocations: SourcingData[],
type: SCENARIO_INTERVENTION_TYPE,
): Promise<ScenarioIntervention> {
Function addOrganisationalEntityFilters
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private addOrganisationalEntityFilters(
baseImpactMapFilters: BaseImpactMapFiltersType,
queryBuilder: { subQueryBuilder: SelectQueryBuilder<any> },
): SelectQueryBuilder<any> {
const {
Function calculateIndicatorSumByYear
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private calculateIndicatorSumByYear(
entityMap: Map<
string,
Map<number, ScenarioVsScenarioImpactTableRowsValues>
>,
Function geoCodePointOfProduction
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
async geoCodePointOfProduction(sourcingData: SourcingData): Promise<any> {
if (!sourcingData.locationCountryInput)
throw new Error(
'A country must be provided for Point of Production location type',
);
- 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 useAllContextualLayersData
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const useAllContextualLayersData = <T = { layerId: Layer['id'] } & H3APIResponse>(
options?: Omit<
UseQueryOptions<
{ layerId: Layer['id'] } & H3APIResponse,
ErrorResponse,
Function parseNode
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
parseNode(
node: AnyImpactTableRows,
indicatorName:
| Pick<ImpactTableDataByIndicator, 'indicatorShortName'>
| string,
Function getTotalPurchasedVolumeByYear
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
getTotalPurchasedVolumeByYear(
rangeOfYears: number[],
dataForImpactTable: ImpactTableData[],
lastYearWithData: number,
scenarioId?: string,