code: public static int countFileLines(final File file) {
          int res = -1;
  
          try (LineNumberReader reader = new LineNumberReader(new FileReader(file));) {
  
              // Read each line to increment the line number of the reader
              while (reader.readLine() != null) {
                  ;// NOSONAR Just Count lines
              }
              // Extract the current line number
              res = reader.getLineNumber();
  
          } catch (final IOException e) {
              LOGGER.error(COUNT_LINES_ERROR, e, file.getAbsolutePath());
          }
          return res;
      }
docs: Count the number of line of the given file. <br />
  If an exception occurred it will be logged and then return -1
  
  @param file the file to inspect
  
  @return the number of lines of the file or -1