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

162
Vistas
Obj: devolver inmediatamente esta expresión en lugar de asignarla a la variable temporal
 const whiteListUrls = await this.whiteListDomainsRepository.find({ where: {and: [{isActive: true}, {type: 'redirect'}]}, });

Este whiteListUrls da una matriz como:

 [ 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 } ]

whiteListUrls devuelve whiteListDomainId . Quiero cambiar ese nombre de clave a una sola identificación . Además, no podemos sobrescribir whiteListUrls tal como se inicializó desde la consulta de db. Así que a continuación está el enfoque que probé. Pero el error de SonarQube dice "obj: devolver inmediatamente esta expresión en lugar de asignarla a la variable temporal"

 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;

¿Hay alguna forma mejor optimizada de hacerlo?

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

0

obj: devuelve inmediatamente esta expresión en lugar de asignarla a la variable temporal

Lo que significa ese error es que quiere que hagas esto en su lugar:

 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