Vizzuality/landgriffon

View on GitHub

Showing 1,408 of 1,408 total issues

Function validate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  validate(longitudeInput: number, args: ValidationArguments): boolean {
    if (
      (args.object as SourcingDataExcelValidator).location_type ===
        LOCATION_TYPES.UNKNOWN ||
      (args.object as SourcingDataExcelValidator).location_type ===

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 useBusinessUnitsOptionsTrees has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const useBusinessUnitsOptionsTrees = <T = BusinessUnitsOption[]>(
  params: BusinessUnitsTreesParams = {},
  options: UseQueryOptions<{ data: BusinessUnitsTreeItem[] }, unknown, T> = {},
): UseQueryResult<T, unknown> => {
  const query = useQuery<{ data: BusinessUnitsTreeItem[] }, unknown, T>(
Severity: Minor
Found in client/src/hooks/business-units/index.ts - About 1 hr to fix

    Function getAvailableYearsForContextualLayer has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async getAvailableYearsForContextualLayer(yearsRequestParams: {
        layerType: LAYER_TYPES;
        h3DataIds?: string[] | null;
        indicatorId?: string;
      }): Promise<number[]> {
    Severity: Minor
    Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 hr to fix

      Function getYears has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async getYears(yearsRequestParams: {
          layerType: LAYER_TYPES;
          h3DataIds?: string[] | null;
          indicatorId?: string;
        }): Promise<number[]> {
      Severity: Minor
      Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 hr to fix

        Function saveGeoRegionAsRadius has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async saveGeoRegionAsRadius(
            newGeoRegionValues: LocationGeoRegionDto,
          ): Promise<string> {
            const selectQuery: SelectQueryBuilder<any> = this.dataSource
              .createQueryBuilder()
        Severity: Minor
        Found in api/src/modules/geo-regions/geo-region.repository.ts - About 1 hr to fix

          Function up has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public async up(queryRunner: QueryRunner): Promise<void> {
              await queryRunner.query(`
                CREATE OR REPLACE FUNCTION sum_weighted_water_over_georegion(
              geo_region_id uuid
             )
          Severity: Minor
          Found in api/src/migrations/1654502331040-WaterIndicatorColumnNameUpdate.ts - About 1 hr to fix

            Function intercept has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async intercept(
                context: ExecutionContext,
                next: CallHandler,
              ): Promise<Observable<any>> {
                if (this.scenarioAcl.isUserAdmin()) {

              Function getEntityAncestryFlatArray has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async getEntityAncestryFlatArray<Entity extends ObjectLiteral>(
                  queryBuilder: SelectQueryBuilder<Entity>,
                  entityName: string,
                ): Promise<Entity[]> {
                  const [subQuery, subQueryParams]: [string, any[]] =
              Severity: Minor
              Found in api/src/utils/tree.repository.ts - About 1 hr to fix

                Function isComparisonRequestAuthorized has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private async isComparisonRequestAuthorized(
                    request: Request,
                    additionalChecks: ScenarioCheckWhiteListOptions,
                  ): Promise<boolean> {
                    const baseScenarioId: string = request.query.baseScenarioId as string;

                  Function up has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    public async up(queryRunner: QueryRunner): Promise<void> {
                      await queryRunner.query(
                        'DROP MATERIALIZED VIEW IF EXISTS impact_materialized_view;',
                      );
                      await queryRunner.query(`

                    Function down has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      public async down(queryRunner: QueryRunner): Promise<void> {
                        await queryRunner.query(`
                        CREATE OR REPLACE FUNCTION sum_weighted_water_over_georegion(
                        geo_region_id uuid
                       )
                    Severity: Minor
                    Found in api/src/migrations/1654502331040-WaterIndicatorColumnNameUpdate.ts - About 1 hr to fix

                      Function handleSourceDataSelect has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        private handleSourceDataSelect(
                          queryBuilder: SelectQueryBuilder<SourcingRecord>,
                          dto: GetImpactTableDto,
                        ): SelectQueryBuilder<SourcingRecord> {
                          if (dto.scenarioId) {
                      Severity: Minor
                      Found in api/src/modules/impact/impact.repository.ts - About 1 hr to fix

                        Function Search has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export const Search: FC<SearchProps> = ({ ...props }: SearchProps) => {
                          const { placeholder } = props;
                          const state = useSearchFieldState(props);
                        
                          const ref = useRef();
                        Severity: Minor
                        Found in marketing/src/components/search/component.tsx - About 1 hr to fix

                          Function TheServicePage has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const TheServicePage: NextPage<PageProps> = () => {
                            return (
                              <ApplicationLayout>
                                <>
                                  <Head>
                          Severity: Minor
                          Found in marketing/src/pages/the-service.tsx - About 1 hr to fix

                            Function PrivacyPolicyPage has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const PrivacyPolicyPage: NextPage<PageProps> = () => {
                              return (
                                <ApplicationLayout>
                                  <>
                                    <Head>
                            Severity: Minor
                            Found in marketing/src/pages/privacy-policy.tsx - About 1 hr to fix

                              Function Compliance has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const Compliance: React.FC = () => {
                                useEffect(() => {
                                  let timerId: number;
                              
                                  if (window.location.hash && document.querySelector(window.location.hash)) {
                              Severity: Minor
                              Found in marketing/src/containers/compliance/component.tsx - About 1 hr to fix

                                Similar blocks of code found in 11 locations. Consider refactoring.
                                Open

                                export class UnitConversionRepository extends Repository<UnitConversion> {
                                  constructor(private dataSource: DataSource) {
                                    super(UnitConversion, dataSource.createEntityManager());
                                  }
                                }
                                api/src/modules/cached-data/cached-data.repository.ts on lines 6..10
                                api/src/modules/indicator-coefficients/indicator-coefficient.repository.ts on lines 6..10
                                api/src/modules/indicators/indicator.repository.ts on lines 9..13
                                api/src/modules/materials/material-indicator-to-h3.service.ts on lines 7..11
                                api/src/modules/scenarios/scenario.repository.ts on lines 6..10
                                api/src/modules/sourcing-location-groups/sourcing-location-group.repository.ts on lines 6..10
                                api/src/modules/targets/targets.repository.ts on lines 6..10
                                api/src/modules/tasks/tasks.repository.ts on lines 6..10
                                api/src/modules/units/unit.repository.ts on lines 6..10
                                api/src/modules/url-params/url-param.repository.ts on lines 6..10

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 56.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

                                Similar blocks of code found in 11 locations. Consider refactoring.
                                Open

                                export class UrlParamRepository extends Repository<UrlParam> {
                                  constructor(private dataSource: DataSource) {
                                    super(UrlParam, dataSource.createEntityManager());
                                  }
                                }
                                Severity: Major
                                Found in api/src/modules/url-params/url-param.repository.ts and 10 other locations - About 1 hr to fix
                                api/src/modules/cached-data/cached-data.repository.ts on lines 6..10
                                api/src/modules/indicator-coefficients/indicator-coefficient.repository.ts on lines 6..10
                                api/src/modules/indicators/indicator.repository.ts on lines 9..13
                                api/src/modules/materials/material-indicator-to-h3.service.ts on lines 7..11
                                api/src/modules/scenarios/scenario.repository.ts on lines 6..10
                                api/src/modules/sourcing-location-groups/sourcing-location-group.repository.ts on lines 6..10
                                api/src/modules/targets/targets.repository.ts on lines 6..10
                                api/src/modules/tasks/tasks.repository.ts on lines 6..10
                                api/src/modules/unit-conversions/unit-conversion.repository.ts on lines 6..10
                                api/src/modules/units/unit.repository.ts on lines 6..10

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 56.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

                                Similar blocks of code found in 11 locations. Consider refactoring.
                                Open

                                export class CachedDataRepository extends Repository<CachedData> {
                                  constructor(private dataSource: DataSource) {
                                    super(CachedData, dataSource.createEntityManager());
                                  }
                                }
                                Severity: Major
                                Found in api/src/modules/cached-data/cached-data.repository.ts and 10 other locations - About 1 hr to fix
                                api/src/modules/indicator-coefficients/indicator-coefficient.repository.ts on lines 6..10
                                api/src/modules/indicators/indicator.repository.ts on lines 9..13
                                api/src/modules/materials/material-indicator-to-h3.service.ts on lines 7..11
                                api/src/modules/scenarios/scenario.repository.ts on lines 6..10
                                api/src/modules/sourcing-location-groups/sourcing-location-group.repository.ts on lines 6..10
                                api/src/modules/targets/targets.repository.ts on lines 6..10
                                api/src/modules/tasks/tasks.repository.ts on lines 6..10
                                api/src/modules/unit-conversions/unit-conversion.repository.ts on lines 6..10
                                api/src/modules/units/unit.repository.ts on lines 6..10
                                api/src/modules/url-params/url-param.repository.ts on lines 6..10

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 56.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

                                Similar blocks of code found in 11 locations. Consider refactoring.
                                Open

                                export class SourcingLocationGroupRepository extends Repository<SourcingLocationGroup> {
                                  constructor(private dataSource: DataSource) {
                                    super(SourcingLocationGroup, dataSource.createEntityManager());
                                  }
                                }
                                api/src/modules/cached-data/cached-data.repository.ts on lines 6..10
                                api/src/modules/indicator-coefficients/indicator-coefficient.repository.ts on lines 6..10
                                api/src/modules/indicators/indicator.repository.ts on lines 9..13
                                api/src/modules/materials/material-indicator-to-h3.service.ts on lines 7..11
                                api/src/modules/scenarios/scenario.repository.ts on lines 6..10
                                api/src/modules/targets/targets.repository.ts on lines 6..10
                                api/src/modules/tasks/tasks.repository.ts on lines 6..10
                                api/src/modules/unit-conversions/unit-conversion.repository.ts on lines 6..10
                                api/src/modules/units/unit.repository.ts on lines 6..10
                                api/src/modules/url-params/url-param.repository.ts on lines 6..10

                                Duplicated Code

                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                Tuning

                                This issue has a mass of 56.

                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                Refactorings

                                Further Reading

                                Severity
                                Category
                                Status
                                Source
                                Language