title: //NonCompliant comment usage - SonarQube Custom Rule
body: <p>I am trying to write a few SONARQUBE custom rules for my project.
  After reading up the below document - 
  <a href="https://docs.sonarqube.org/display/PLUG/Writing+Custom+Java+Rules+101" rel="nofollow noreferrer">https://docs.sonarqube.org/display/PLUG/Writing+Custom+Java+Rules+101</a>
  and 
  <a href="https://github.com/SonarSource/sonar-custom-rules-examples" rel="nofollow noreferrer">https://github.com/SonarSource/sonar-custom-rules-examples</a>,
  I created a custom rule like these classes below - </p>
  
  <p>The Rule file:</p>
  
  <pre><code>@Rule(key = "MyAssertionRule")
  public class FirstSonarCustomRule extends BaseTreeVisitor implements JavaFileScanner {
  
      private static final String DEFAULT_VALUE = "Inject";
      private JavaFileScannerContext context;
      /**
       * Name of the annotation to avoid. Value can be set by users in Quality
       * profiles. The key
       */
      @RuleProperty(defaultValue = DEFAULT_VALUE, description = "Name of the annotation to avoid, without the prefix @, for instance 'Override'")
      protected String name;
  
      @Override
      public void scanFile(JavaFileScannerContext context) {
          this.context = context;
          System.out.println(PrinterVisitor.print(context.getTree()));
          scan(context.getTree());
      }
  
      @Override
      public void visitMethod(MethodTree tree) {
          List&lt;StatementTree&gt; statements = tree.block().body();
  
          for (StatementTree statement : statements) {
              System.out.println("KIND IS " + statement.kind());
              if (statement.is(Kind.EXPRESSION_STATEMENT)) {
                  if (statement.firstToken().text().equals("Assert")) {
                      System.out.println("ERROR");
  
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>The Test class:</p>
  
  <pre><code>public class FirstSonarCustomRuleTest {
  
      @Test
      public void verify() {
          FirstSonarCustomRule f = new FirstSonarCustomRule();
          f.name = "ASSERTION";
          JavaCheckVerifier.verify("src/test/files/FirstSonarCustom.java", f);
      }
  }
  </code></pre>
  
  <p>And finally - the <code>Test</code> file:</p>
  
  <pre><code>class FirstSonarCustom {
  
      int aField;
  
      public void methodToUseTestNgAssertions() {
          Assert.assertTrue(true);
      }
  }
  </code></pre>
  
  <p>The above Test file would later be my Project's source code.
  As per the SONAR documentation - the // Noncompliant is a mandatory comment in my Test file. Thus my first question is should I add this comment everywhere in my Source code too?
  If yes - is there any way I can avoid adding this comment, because I do not want to add that code refactoring exercise all over.</p>
  
  <p>Can someone suggest me what I need to do here? </p>
  
  <p>I am using SONARQUBE 6.3.</p>