Translation and UniqueProperties rules in gradle

47 views
Skip to first unread message

Ievgen

unread,
Apr 5, 2016, 9:32:54 AM4/5/16
to checkstyle
I have multi module gradle project. Checkstyle modules Translation and UniqueProperties  don't work for me. I can't trigger violation.

My config:
type ..\gradle\checkstyle2.xml
<?xml version="1.0" encoding="UTF-8"?>
<!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="Translation">
       
<property name="requiredTranslations" value="de, fr, en"/>
   
</module>

   
<module name="UniqueProperties"/>

   
<!--<module name="FileTabCharacter"/>-->
</module>

gradle config:
checkstyle {
    toolVersion
= "6.17"
    sourceSets = [sourceSets.main]
    ignoreFailures
= true   //todo
    showViolations = true
    reportsDir = file("$project.buildDir/checkstyleReports")
    configFile
= file("$rootDir/gradle/checkstyle2.xml")
    configProperties
= ['baseDir': "$project.projectDir"]
}

type src\main\resources\messages.properties
#messages.properties
hello=Hello
cancel=Cancel

type src\main\resources\messages_de.properties
#messages_de.properties
hell=Hallo
ok=OK

hell=Hallo2


I run gradle in this way:
gradle clean checkstyleMain
but it doesn't show any violations

I run checkstyle client:
java -jar ../checkstyle-6.17-all.jar -c ../gradle/checkstyle2.xml src/main

Output:
Starting audit...
*****
[ERROR] ****\src\main\resources\messages_de.properties:2: Duplicated property 'hell' (2 occurrence(s)). [UniqueProperties]
[ERROR] ****\src\main\resources:0: Properties file 'messages_en.properties' is missing. [Translation]
[ERROR] ****\src\main\resources:0: Properties file 'messages_fr.properties' is missing. [Translation]
[ERROR] src\main\resources\messages_de.properties:0: Key 'cancel' missing. [Translation]
[ERROR] src\main\resources\messages_de.properties:0: Key 'hello' missing. [Translation]
[ERROR] src\main\resources\messages.properties:0: Key 'hell' missing. [Translation]
[ERROR] src\main\resources\messages.properties:0: Key 'ok' missing. [Translation]
Audit done.
Checkstyle ends with 9 errors.


If I turn on FileTabCharacter module and run gradle, it'll show violations.

I can reproduce this bug with:
checkstyle 6.17, 6.16.1
gradle 2.8, 2.12
java 8
multi module project with maven archetypes

maybe there is problem with 
sourceSets = [sourceSets.main]
and checkstyle plugin doesn't see any resources?

Do you have any ideas how to fix the problem to show Translation viiolations?



Roman Ivanov

unread,
Apr 6, 2016, 8:56:54 PM4/6/16
to Ievgen, checkstyle
Hi levgen,

It is gradle plugin problem, you need to go for solution to their support.

for your case I can not make work even simple "<module name="NewlineAtEndOfFile"/>" so, it is not related to Translation Check.




Please share a solution as you find it.

thanks,
Roman Ivanov

Ievgen

unread,
Apr 8, 2016, 2:18:00 AM4/8/16
to checkstyle

Until bug https://issues.gradle.org/browse/GRADLE-3432 isn't fixed just add

checkstyleMain {
   
source sourceSets.main.allSource
}



Reply all
Reply to author
Forward
0 new messages