Repository: checkstyle/checkstyle (Java)

Issue:
Regexp: violation pointing to line 0 while other Checks count first line as 1
https://checkstyle.org/checks/regexp/regexp.html#Regexp

problem is detected at https://github.com/checkstyle/checkstyle/pull/14057 and blocks it as test suite can not accept line 0 as expected. 

```
$ cat config.xml 
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name="Checker">
  <module name="TreeWalker">
    <module name="Regexp">
      <property name="format" value="// This code is copyrighted"/>
    </module>
  </module>
</module>

$ cat Test.java 
// comment
public class TestClass {
}

$ java -jar checkstyle-10.12.4-all.jar -c config.xml Test.java
Starting audit...
[ERROR] /var/tmp/Test.java:0: Required pattern '// This code is copyrighted' missing in file. [Regexp]
Audit done.
Checkstyle ends with 1 errors.

```


example for other Check that shows that line number is 1
```
$ cat config.xml 
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name="Checker">
      <module name="FileLength">
        <property name="max" value="1"/>
      </module>
</module>

$ cat Test.java 
// comment
public class TestClass {
}

$ java -jar checkstyle-10.12.4-all.jar -c config.xml Test.java
Starting audit...
[ERROR] /var/tmp/Test.java:1: File length is 3 lines (max allowed is 1). [FileLength]
Audit done.
Checkstyle ends with 1 errors.
```

prove in code that line length starts from 1: https://github.com/checkstyle/checkstyle/blob/55097468aa37d890b0e7b89ac2d27d08c16aee59/src/main/java/com/puppycrawl/tools/checkstyle/api/FileText.java#L279-L280

Expected:
`[ERROR] /var/tmp/Test.java:1: Required pattern '// This code is copyrighted' missing in file. [Regexp]`



Fix (patch):
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpCheck.java
index f60e9d31df7..8a0edbacf87 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpCheck.java
@@ -327,7 +327,8 @@ private void findMatch() {
             }
         }
         else if (!illegalPattern && matchCount == 0) {
-            logMessage(0);
+            final String msg = getMessage();
+            log(1, MSG_REQUIRED_REGEXP, msg);
         }
     }
 
@@ -378,6 +379,22 @@ private boolean isIgnore(int startLine, FileText text, LineColumn start) {
      * @param lineNumber the line number the message relates to.
      */
     private void logMessage(int lineNumber) {
+        final String msg = getMessage();
+
+        if (illegalPattern) {
+            log(lineNumber, MSG_ILLEGAL_REGEXP, msg);
+        }
+        else {
+            log(lineNumber, MSG_DUPLICATE_REGEXP, msg);
+        }
+    }
+
+    /**
+     * Provide right message.
+     *
+     * @return message for violation.
+     */
+    private String getMessage() {
         String msg;
 
         if (message == null || message.isEmpty()) {
@@ -391,17 +408,7 @@ private void logMessage(int lineNumber) {
             msg = ERROR_LIMIT_EXCEEDED_MESSAGE + msg;
         }
 
-        if (illegalPattern) {
-            log(lineNumber, MSG_ILLEGAL_REGEXP, msg);
-        }
-        else {
-            if (lineNumber > 0) {
-                log(lineNumber, MSG_DUPLICATE_REGEXP, msg);
-            }
-            else {
-                log(lineNumber, MSG_REQUIRED_REGEXP, msg);
-            }
-        }
+        return msg;
     }
 
 }