title: How to re-write function without generic object injection sink in AngularJS?
body: <p>I have a function and it works just fine, but <a href="http://www.codacy.com" rel="nofollow noreferrer">codacy</a> inspection says it is bad practice to do so. I understand that it even looks unsafe, but I cannot come up with how to do it another, better, way.</p>
  
  <pre><code>    function getCount(i) {
  
          var iCount = iCount || 0;
  
          for (var item in this.items) {
              for (var level1 in this.items[item]) {
                  for (var level2 in this.items[item][level1]) {
                      for (var level3 in this.items[item][level1][level2]) {
                          if (this.items[item][level1][level2][level3] == i) {
                              iCount++;
                          }
                      }
                  }
              }
          }
          return iCount;
      }
  </code></pre>
  
  <p>After Icycool's advices I came up with something more acceptable. I tried to use forEach loop, but it didn't work so I decided to use a fori. Though it is not perfect it'll do for now:</p>
  
  <pre><code>    function getCount(i) {
          var iCount = iCount || 0;
              for (var y = 0; y &lt; this.items["content"].length; y++) {
                  if (this.items["content"][y]["custom_object"]["id"] === i) {
                      iCount++;
                  }
              }
          return iCount;
      }
  </code></pre>