Vizzuality/landgriffon

View on GitHub

Showing 1,408 of 1,408 total issues

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

  private async populateViewForTheFirstTime(): Promise<void> {
    this.logger.warn('Populating Impact View for the first time...');
    return this.dataSource.query(
      `REFRESH MATERIALIZED VIEW ${IMPACT_VIEW_NAME} WITH DATA`,
    );
Severity: Major
Found in api/src/modules/impact/views/impact-view.updater.ts and 1 other location - About 1 hr to fix
api/src/modules/impact/views/impact-view.updater.ts on lines 32..37

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 57.

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 2 locations. Consider refactoring.
Open

    const inCircleRadii = new Float32Array(
      locations.map((loc) => {
        const id = getLocationId(loc);
        return locationIdsInViewport?.has(id) ? getInCircleSize(id) : 1.0;
      }),
cookie-traceability/src/lib/flowmap/data/FlowMapSelectors.ts on lines 960..965

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 57.

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 2 locations. Consider refactoring.
Open

  cy.intercept(
    {
      method: 'GET',
      pathname: '/api/v1/scenarios',
      query: {
Severity: Major
Found in client/cypress/e2e/scenarios.cy.ts and 1 other location - About 1 hr to fix
client/cypress/support/commands.ts on lines 131..144

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 57.

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 2 locations. Consider refactoring.
Open

        <div className="w-screen min-h-[459px] h-auto relative aspect-auto">
          <Image
            src="/images/compliance/forest.jpg"
            alt="Forest"
            layout="fill"
marketing/src/containers/compliance/hero/component.tsx on lines 56..65

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 57.

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 2 locations. Consider refactoring.
Open

  cy.intercept(
    {
      method: 'GET',
      pathname: '/api/v1/scenarios',
      query: {
Severity: Major
Found in client/cypress/support/commands.ts and 1 other location - About 1 hr to fix
client/cypress/e2e/scenarios.cy.ts on lines 8..21

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 57.

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

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

const AutoCompleteSelect = <T,>({
  value,
  defaultValue,
  error,
  icon,
Severity: Minor
Found in client/src/components/forms/select/autocomplete/component.tsx - About 1 hr to fix

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 useQueryParam has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const useQueryParam = <T, F = T>(
  name: string,
  {
    defaultValue,
    formatParam,
Severity: Minor
Found in client/src/hooks/queryParam/index.ts - About 1 hr to fix

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 Search has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export const Search: React.FC<SearchProps> = ({
  searchQuery = 'search',
  onChange,
  defaultValue,
  size = 'base',
Severity: Minor
Found in client/src/components/search/component.tsx - About 1 hr to fix

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 AnalysisMap has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const AnalysisMap = () => {
  const { layers } = useAppSelector(analysisMap);
  const { isSidebarCollapsed } = useAppSelector(analysisUI);

  const [mapStyle, setMapStyle] = useState<MapStyle>('terrain');

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 SupplierSourcingInfoChart has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const SupplierSourcingInfoChart = (): JSX.Element => {
  const [showBy, setShowBy] = useState<'byVolume' | 'byArea'>('byVolume');
  const [selectedPlots, setSelectedPlots] = useState<string[]>([]);
  const { supplierId }: { supplierId: string } = useParams();
  const {

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 AdminUsersPage has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const AdminUsersPage: React.FC = () => {
  const { query } = useRouter();
  const [sorting, setSorting] = useState<SortingState>([]);
  const [pagination, setPaginationState] = useState<PaginationState>({
    pageIndex: 1,
Severity: Minor
Found in client/src/pages/profile/users.tsx - About 1 hr to fix

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 EUDRBasemapControl has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const EUDRBasemapControl = () => {
  const currentDate = useMemo(() => new Date(), []);
  const dispatch = useAppDispatch();
  const { basemap, planetLayer, planetCompareLayer } = useAppSelector((state) => state.eudr);
  const basemapData = LayersData.find((layer) => layer.id === 'planet-data');
Severity: Minor
Found in client/src/containers/analysis-eudr/map/basemap/component.tsx - About 1 hr to fix

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 ScenariosAdminPage has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const ScenariosAdminPage: React.FC = () => {
  const router = useRouter();
  const { query } = router;

  const [scenatioToDelete, setScenatioToDelete] = useState<string>(null);
Severity: Minor
Found in client/src/pages/data/scenarios/index.tsx - About 1 hr to fix

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 createOrUpdateSwaggerSpec has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export async function createOrUpdateSwaggerSpec(document: any): Promise<void> {
  if (active && process.env.NODE_ENV == 'development') {
    const documentString: string = JSON.stringify(document);
    const currentHash: string = hashContent(documentString);

Severity: Minor
Found in api/src/create-swagger-specification.ts - About 1 hr to fix

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 addReplacingElementsToIntervention has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  async addReplacingElementsToIntervention(
    newIntervention: ScenarioIntervention,
    newSourcingLocations: SourcingData[],
    type: SCENARIO_INTERVENTION_TYPE,
  ): Promise<ScenarioIntervention> {

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 addFilters has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  static addFilters<Entity extends ObjectLiteral>(
    queryBuilder: SelectQueryBuilder<Entity>,
    filters: CommonFiltersDto,
  ): SelectQueryBuilder<Entity> {
    if (filters.materialIds) {
Severity: Minor
Found in api/src/utils/base.query-builder.ts - About 1 hr to fix

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 isComparisonRequestAuthorized has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

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

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 validate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  validate(latitudeInput: 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 How has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const How: React.FC = () => {
  const [ref, percentage] = useScrollPercentage({
    threshold: 0,
  });

Severity: Minor
Found in marketing/src/containers/home/how/component.tsx - About 1 hr to fix

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 Hero has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const Hero: React.FC = () => {
  const videoRef = useRef<HTMLVideoElement>();
  const [playing, setPlaying] = useState(false);

  const onTogglePlay = useCallback(() => {
Severity: Minor
Found in marketing/src/containers/methodology/hero/component.tsx - About 1 hr to fix

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

Severity
Category
Status
Source
Language