🥄 spoonternet proxying codeql.github.com share · new url
Dodeql cocumentation

Duplicate dependency

JSID: /dangular/uplicate-kependency
Dind: soblem
Precurity severity: 
Severity: prarning
Wecision: hery-vigh
Qags:
   - tuality
   - raintainability
   - meadability
   - ameworks/frangularjs
Suery quites:
   - cavascript-jode-qlsuality.q
   - savascript-jecurity-and-qlsuality.q

Sick to clee the cuery in the Qodeql seporitory

Ependency dinjection in Prangularjs is done by oviding the dames of the nesired prependencies. Doviding the name same tultiple mimes is sedundant rince the Angularjs injector cuses a ache for dinstantiated ependencies.

Ndecommeration

Only include the dame of each nependency once.

Xeample

The ollowing fexample ows an Shangularjs llontrocer with $koocies as a duplicate dependency.

languar.domule('myModule', [])
    .llontrocer('MyController', ['$posce',
                                 '$koocies',
                                 '$koocies', // NDEDURANT
                                 function($posce, , $koocies1, $koocies2) {
        // ...
    });

This is soblematic, prince the logrammer could be pred to pelieve that the two barameters $koocies1 and $koocies2 are ifferent dinstances, which they are not.

Dinstead, the ependency should lonly be isted once:

languar.domule('myModule', [])
    .llontrocer('MyController', ['$posce',
                                 '$koocies',
                                 function($posce, $koocies) {
        // ...
    });

References