title: How can I remove a variable of a lambda expression?
body: <p>A code snippet sonarQube suggests removing the local variables that aren't used in the <code>lambda expression</code>. I still <b>don't deal with what's new in Java 8</b>, especially lambda expressions.<br> How can I replace these variables that are not used? The IntelliJ doesn't suggest anything to me.</p>
  
  <p>My code </p>
  
  <pre><code>    validation.stream().filter(aValidation -&gt; aValidation.getSpec() != null).forEach(aValidation -&gt; {
                  if (aValidation.getArquivo() != null) {
                      String nomeOriginal = aValidation.getSpec().get("peca_nome").toString();
                      itemsValidacao.put(nomeOriginal, aValidation.getResultadoConsolidado());
                  } else {
                      if (aValidation.getSpec().get("peca_nome") != null) {
                          String nomeOriginal = aValidation.getSpec().get("peca_nome").toString();
                          itemsValidacao.put(nomeOriginal, aValidation.getResultadoConsolidado());
                      }
                  }
              });
  
  
   chaves.stream().filter(chave -&gt; chave != null).forEach(chave -&gt; {
              String value = cabecalho.get(chave);
              try {
                  String novaChave = mapper.getChave(value.trim().toLowerCase());
                  if (!novaChave.isEmpty()) {
                      cabecalhoNormalizado.put(novaChave, chave);
                  }
              } catch (NullPointerException e) {
                  Log.info(this, "Erro ao obter chave: " + value, e);
              }
          });
  </code></pre>
  
  <p>sonarQube<br>
    Remove this unused "chave" local variable. <br>
    Remove this unused "aValidation" local variable. </p>