简体   繁体   中英

Yamllint exclude @ symbol check in application.yaml file

I have used linter to lint spring-boot framework application.yaml file:

---
spring:
  application:
    name: @project.name@

@project.name@ value allows spring-boot application to resolve application name from pom.xml file.
However when I run linter ( yamllint./src/main/ ) I get an error:
Error: ./src/main/resources/application.yaml:4:11: [error] syntax error: found character '@' that cannot start any token (syntax)


Is there any rule how can I exclude special characters check?

That's a syntax error. yamllint uses PyYAML for parsing, which yields this error. PyYAML obviously cannot ignore a syntax error, and by extension, yamllint cannot ignore it.

Your best bet is to preprocess the file to replace all referenced variables, eg

sed -E 's/@([^@]*)@/_\1_/g' application.yaml | yamllint -

This replaces the @ characters around variable references with _ , which keeps the line length.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM