Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
Obj: Immediately return this expression instead of assigning it to the temporary variable
  const whiteListUrls = await this.whiteListDomainsRepository.find({
    where: {and: [{isActive: true}, {type: 'redirect'}]},
  });

This whiteListUrls give a array like:

[
    WhiteListDomain {
    whiteListDomainId: '62b068307bed2ef2c57c4bbf',
    domain: 'go.pampers.com',
    isActive: true,
    type: 'redirect',
    createdDate: 2021-03-25T06:11:53.974Z,
    createdBy: 'thakkar.dt.1@pg.com',
    updatedBy: 'thakkar.dt.1@pg.com',
    updatedDate: 2021-03-25T06:13:53.545Z
    },
    WhiteListDomain {
    whiteListDomainId: '62b068f87bed2ef2c57c4bc0',
    domain: 'app.adjust.com',
    isActive: true,
    type: 'redirect',
    createdDate: 2021-03-25T06:11:53.974Z,
    createdBy: 'thakkar.dt.1@pg.com',
    updatedBy: 'thakkar.dt.1@pg.com',
    updatedDate: 2021-03-25T06:13:53.545Z
    }
]

The whiteListUrls returns whiteListDomainId I want to change that key name to ony id Also we cannot overrwite whiteListUrls as it initialized from the db query. So below is the approach i tried. But SonarQube error says " obj: Immediately return this expression instead of assigning it to the temporary variable"

  interface GetWhiteListesdUrls {
    id: string;
    domain: string;
    isActive: boolean;
    type: string;
    createdDate: string;
    createdBy: string;
    updatedDate: string;
    updatedBy: string;
  }

  const urls = whiteListUrls.map(element => {
    const obj: GetWhiteListesdUrls = {
      id: element.whiteListDomainId!,
      domain: element.domain,
      isActive: element.isActive!,
      type: element.type,
      createdDate: element.createdDate,
      createdBy: element.createdBy,
      updatedDate: element.updatedDate,
      updatedBy: element.updatedBy,
    };
    return obj;
  });
  return urls;

Is there any better optimized way to do it ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

obj: Immediately return this expression instead of assigning it to the temporary variable

What that error means is that it wants you do this instead:

  return whiteListUrls.map(element => {
    const obj: GetWhiteListesdUrls = {
      id: element.whiteListDomainId!,
      domain: element.domain,
      isActive: element.isActive!,
      type: element.type,
      createdDate: element.createdDate,
      createdBy: element.createdBy,
      updatedDate: element.updatedDate,
      updatedBy: element.updatedBy,
    };
    return obj;
  });
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda