# from: https://raw.githubusercontent.com/sk-/git-lint/master/gitlint/configs/config.yaml
#
# Copyright 2013-2014 Sebastian Kreft
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Regular expression matchers like \d, \w, must be escaped as in \\d, \\w.
# If you need to include a string like '{}' or '{foo}', you need to double the
# braces, as in '{{}}' or '{{foo}}'. See the pylint configuration for an
# example.

# NOTE: filter are regular expressions, and for readability they are broken up
# using '>-' line folding from YAML. This means that between each line a space
# will be added.

# JSON
# Sample output:
# Expecting property name: line 3 column 5 (char 15)
json:
  extensions:
    - .json
  command: python
  arguments:
    - -m
    - json.tool
  # enforce that here comes a colon
  filter: >-
    ^(?P<message>[^:]+(?=:
    line \d+ column \d+)|No JSON object could be decoded)(:
    line (?P<line>\d+) column (?P<column>\d+).*)?$
  installation: Nothing else should be required.

# SHELL scripts
# Sample output
# /path_to/error.sh: line 3: syntax error: unexpected end of file
bash:
  extensions:
    - .sh
  command: ash
  arguments:
    - "-n"
  filter: >-
    {filename}: line (?P<line>{lines}): (?P<message>.+)
  installation: Please install ash in your system.

# YAML
yaml:
  extensions:
    - .yaml
    - .yml
  command: yamllint
  arguments:
    - --format
    - parsable
    - --config-data
    - "{{extends: default, rules: {{document-start: disable}}}}"
  # Matches either:
  # - syntax error, on any line
  # - other error, on a modified line only
  filter: >-
    ^{filename}:(?P<line>{lines}|\d+(?=:\d+:
    \[error\] syntax error:)):(?P<column>\d+):
    \[(?P<severity>\S+)\] (?P<message>.+)$

  installation: Run pip install yamllint.

# Java
# Sample output:
# /path_to/error.java:0: Missing package-info.java file.
# /path_to/error.java:1:7: warning: Name 'foo' must match pattern '^[A-Z][a-zA-Z0-9]*$'.
checkstyle:
  command: checkstyle
  extensions:
    - .java
  requirements:
    - java
  arguments:
    - -c
    - "{DEFAULT_CONFIGS}/checkstyle.xml"
  filter: "{filename}:(?P<line>{lines}):((?P<column>\\d+):)? (?P<message>.+)"
  installation: >-
    sudo apt-get install checkstyle or go to
    http://checkstyle.sourceforge.net/cmdline.html

# Sample output:
# /path_to/error.java:1:  All methods are static.
# Disabled rulesets because of false positives
# rulesets/java/coupling.xml: Demeter
# rulesets/java/design.xml: Static class
# rulesets/java/optimizations.xml: Parameter could be final
# rulesets/java/junit.xml: maximum asserts, asserts should have message
pmd:
  command: ash
  extensions:
    - .java
  requirements:
    - java
  arguments:
    - /usr/local/pmd-bin-6.26.0/bin/run.sh
    - pmd
    - -format
    - text
    - -rulesets
    - "rulesets/java/android.xml,rulesets/java/basic.xml,\
       rulesets/java/braces.xml,rulesets/java/clone.xml,\
       rulesets/java/codesize.xml,rulesets/java/empty.xml,\
       rulesets/java/finalizers.xml,rulesets/java/imports.xml,\
       rulesets/java/j2ee.xml,rulesets/java/logging-jakarta-commons.xml,\
       rulesets/java/strictexception.xml,rulesets/java/strings.xml,\
       rulesets/java/sunsecure.xml,rulesets/java/typeresolution.xml,\
       rulesets/java/unnecessary.xml,rulesets/java/unusedcode.xml"
    - -d
  filter: "{filename}:(?P<line>{lines}):\\s+(?P<message>.+)"
  installation: Go to http://pmd.sourceforge.net/pmd-5.1.1/installing.html

# Kotlin
# Sample output:
# src/main/kotlin/Main.kt:10:10: Unused import
ktlint:
  command: ktlint
  extensions:
    - .kt
    - .kts
  requirements:
    - ktlint
  filter: "^{filename}:(?P<line>{lines}):(?P<column>\\d+): (?P<message>.+)$"
  installation: curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.37.2/ktlint && chmod a+x ktlint

# Markdown
# Sample output:
# README.md:1: MD013 Line length
# README.md:70: MD029 Ordered list item prefix
# README.md:71: MD029 Ordered list item prefix
# README.md:72: MD029 Ordered list item prefix
# README.md:73: MD029 Ordered list item prefix
mdl:
  command: mdl
  extensions:
    - .md
  requirements:
    - mdl
  filter: "^{filename}:(?P<line>{lines}): (?P<message>.+)$"
  installation: gem install mdl
