Showing 438 of 1,408 total issues
Function parseSourcingDataFromSheet
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
async parseSourcingDataFromSheet(customData: WorkSheet[]): Promise<{
sourcingData: SourcingData[];
}> {
this.logger.debug(`Cleaning ${customData.length} custom data rows`);
const sourcingData: SourcingData[] = [];
- 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 DeforestationAlerts
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
const DeforestationAlerts = (): JSX.Element => {
const { supplierId }: { supplierId: string } = useParams();
const {
filters: { dates },
} = useAppSelector(eudrDetail);
Function YearsFilter
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
const YearsFilter: React.FC = () => {
const dispatch = useAppDispatch();
const filters = useAppSelector(analysisFilters);
const { layer, materials, indicator, startYear } = filters;
Function RADDSlider
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
const RADDSlider = () => {
const dispatch = useAppDispatch();
const [values, setValues] = useState<number[]>([0, 0]);
const data = layersData.find((layer) => layer.id === LAYERD_ID);
const dates = data?.legend?.dates;
Function buildImpactTable
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
private buildImpactTable(
queryDto: GetImpactTableDto,
indicators: Indicator[],
dataForImpactTable: ImpactTableData[],
entityTree: ImpactTableEntityType[],
Function groupAndFillAlertsByMonth
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const groupAndFillAlertsByMonth = (
alerts: AlertsOutput[],
geoRegionMap: Map<string, any>,
startDate: Date,
endDate: Date,
Function ImpactBeyondCompliance
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
const ImpactBeyondCompliance: React.FC = () => {
return (
<section className="relative space-y-12 bg-blue-600 md:space-y-64">
<Wrapper>
<div className="space-y-10 text-white md:space-y-20 md:py-32 py-12">
Function createUser
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
async createUser(dto: CreateUserDTO): Promise<Partial<User>> {
const user: User = new User();
user.fname = dto.fname ?? DEFAULT_USER_NAME;
user.lname = dto.lname;
user.title = dto.title;
Function addEntityFiltersToQuery
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
private addEntityFiltersToQuery(
selectQueryBuilder: SelectQueryBuilder<SourcingRecord>,
impactDataDto: GetActualVsScenarioImpactTableDto | GetImpactTableDto,
): SelectQueryBuilder<SourcingRecord> {
if (impactDataDto.materialIds) {
Function geoCodeAdministrativeRegionOfProduction
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
async geoCodeAdministrativeRegionOfProduction(
sourcingData: SourcingData,
): Promise<SourcingData> {
// TODO: Since this has become required for all location types, we should validate this at DTO level
if (!sourcingData.locationCountryInput) {
Function getEntityMetadata
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getEntityMetadata(dto: GetDashBoardDTO): Promise<EntityMetadata[]> {
const queryBuilder: SelectQueryBuilder<EntityMetadata> =
this.datasource.createQueryBuilder();
queryBuilder
.select('s.id', 'supplierId')
Function Hero
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
const Hero: React.FC = () => {
return (
<section className="relative flex flex-col items-center justify-center w-full py-12 overflow-hidden bg-blue-600 md:h-screen">
<div className="absolute top-0 right-0 hidden w-[800px] h-[800px] bg-right-bottom bg-no-repeat pointer-events-none md:block">
<object
Function main
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def main(drop_contextuals: bool, dry_run: bool):
with psycopg.connect(get_connection_info()) as conn:
with conn.cursor() as cursor:
# find all the tables that start with h3_grid*
cursor.execute(
- 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 cluster
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function cluster(points: Point[], zoom: number, tree: ZoomLevelKDBush, options: Options) {
const clusters: Point[] = [];
const { radius, extent } = options;
const r = radius / (extent * Math.pow(2, zoom));
- 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 addGroupAndOrderByToQuery
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private addGroupAndOrderByToQuery(
selectQueryBuilder: SelectQueryBuilder<SourcingRecord>,
impactDataDto: GetActualVsScenarioImpactTableDto | BaseImpactTableDto,
): SelectQueryBuilder<SourcingRecord> {
switch (impactDataDto.groupBy) {
Function getActualVsScenarioImpactMap
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getActualVsScenarioImpactMap(
dto: GetActualVsScenarioImpactMapDto,
): Promise<{ impactMap: H3IndexValueData[]; quantiles: number[] }> {
const baseQueryExtend = (baseQuery: SelectQueryBuilder<any>): void => {
//Add selection criteria to also select both comparedScenario in the select statement
Function serializerConfig
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
get serializerConfig(): JSONAPISerializerConfig<User> {
return {
attributes: [
'fname',
'lname',
Function parseSourcingDataFromSheet
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
async parseSourcingDataFromSheet(customData: WorkSheet[]): Promise<{
sourcingData: SourcingData[];
}> {
this.logger.debug(`Cleaning ${customData.length} custom data rows`);
const sourcingData: SourcingData[] = [];
Function MapPage
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
const MapPage: NextPageWithLayout = () => {
const scrollRef = useRef<HTMLDivElement>(null);
const { planetCompareLayer } = useAppSelector((state) => state.eudr);
const [isCollapsed, setIsCollapsed] = useState(false);
Function GroupByFilter
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
const GroupByFilter: React.FC = () => {
const { replace, query = {} } = useRouter();
const dispatch = useAppDispatch();
const filters = useAppSelector(analysisFilters);