Skip to content

Commit c91634c

Browse files
committed
Initial Checkstyle cfg (rule tuning pending)
1 parent befe396 commit c91634c

File tree

7 files changed

+163
-8
lines changed

7 files changed

+163
-8
lines changed

checkstyle.xml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
2+
3+
<!-- https://github.com/checkstyle/checkstyle/blob/master/config/checkstyle_checks.xml -->
4+
<module name="Checker">
5+
<module name="SeverityMatchFilter">
6+
<property name="severity" value="info"/>
7+
<property name="acceptOnMatch" value="false"/>
8+
</module>
9+
<module name="FileTabCharacter">
10+
<property name="eachLine" value="true"/>
11+
</module>
12+
<module name="SuppressWarningsFilter"/>
13+
<module name="TreeWalker">
14+
<property name="tabWidth" value="4"/>
15+
<property name="severity" value="error"/>
16+
<module name="Indentation">
17+
<property name="basicOffset" value="2"/>
18+
<property name="severity" value="ignore"/>
19+
</module>
20+
<module name="SuppressWarningsHolder"/>
21+
<module name="ConstantName"/>
22+
<module name="FinalLocalVariable">
23+
<property name="severity" value="ignore"/>
24+
</module>
25+
<module name="LocalFinalVariableName"/>
26+
<module name="LocalVariableName"/>
27+
<module name="MemberName">
28+
<property name="format" value="^[a-z][a-zA-Z0-9_]*$"/>
29+
</module>
30+
<module name="MethodName"/>
31+
<module name="PackageName"/>
32+
<module name="ParameterName"/>
33+
<module name="StaticVariableName"/>
34+
<module name="TypeName"/>
35+
<module name="RedundantImport"/>
36+
<module name="UnusedImports">
37+
<property name="processJavadoc" value="true"/>
38+
</module>
39+
<module name="LineLength">
40+
<property name="max" value="130"/>
41+
<property name="ignorePattern" value="^[ \t]*\*.*@.*$"/>
42+
</module>
43+
<module name="MethodLength">
44+
<property name="tokens" value="METHOD_DEF"/>
45+
<property name="max" value="120"/>
46+
</module>
47+
<module name="EmptyForInitializerPad"/>
48+
<module name="MethodParamPad"/>
49+
<module name="NoWhitespaceBefore"/>
50+
<module name="WhitespaceAfter">
51+
<property name="tokens" value="COMMA, SEMI"/>
52+
</module>
53+
<module name="WhitespaceAround"/>
54+
<module name="OperatorWrap">
55+
<property name="tokens" value="PLUS, ASSIGN"/>
56+
<property name="option" value="nl"/>
57+
</module>
58+
<module name="NeedBraces"/>
59+
<module name="ParenPad"/>
60+
<module name="TypecastParenPad"/>
61+
<module name="ModifierOrder"/>
62+
<module name="RedundantModifier"/>
63+
<module name="NestedTryDepth">
64+
<property name="max" value="2"/>
65+
</module>
66+
<module name="CovariantEquals"/>
67+
<module name="LeftCurly">
68+
<property name="option" value="eol"/>
69+
</module>
70+
<module name="RightCurly">
71+
<property name="option" value="same"/>
72+
</module>
73+
<module name="EmptyStatement"/>
74+
<module name="EqualsHashCode"/>
75+
<module name="DefaultComesLast"/>
76+
<module name="SimplifyBooleanExpression"/>
77+
<module name="SimplifyBooleanReturn"/>
78+
<module name="StringLiteralEquality"/>
79+
<module name="PackageDeclaration"/>
80+
<module name="FallThrough"/>
81+
<module name="FinalClass"/>
82+
<module name="MutableException"/>
83+
<module name="TodoComment">
84+
<property name="severity" value="info"/>
85+
<property name="format" value="TODO"/>
86+
</module>
87+
<module name="UpperEll"/>
88+
<module name="IllegalType">
89+
<property name="legalAbstractClassNames" value="AbstractBeanDefinition, AbstractEntry"/>
90+
<property name="illegalClassNames" value="java.util.GregorianCalendar, java.util.Vector"/>
91+
</module>
92+
<module name="DescendantToken">
93+
<property name="tokens" value="LITERAL_ASSERT"/>
94+
<property name="limitedTokens" value="ASSIGN,DEC,INC,POST_DEC,POST_INC,PLUS_ASSIGN,MINUS_ASSIGN,STAR_ASSIGN,DIV_ASSIGN,MOD_ASSIGN,BSR_ASSIGN,SR_ASSIGN,SL_ASSIGN,BAND_ASSIGN,BXOR_ASSIGN,BOR_ASSIGN,METHOD_CALL"/>
95+
<property name="maximumNumber" value="2"/>
96+
</module>
97+
</module>
98+
<module name="Header">
99+
<property name="headerFile" value="${checkstyle.header.file}"/>
100+
<property name="fileExtensions" value="java"/>
101+
</module>
102+
</module>

pom.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,29 @@
372372
<includeTests>true</includeTests>
373373
</configuration>
374374
</plugin>
375+
<plugin>
376+
<groupId>org.apache.maven.plugins</groupId>
377+
<artifactId>maven-checkstyle-plugin</artifactId>
378+
<version>2.17</version>
379+
<executions>
380+
<execution>
381+
<id>check-style</id>
382+
<phase>verify</phase>
383+
<goals>
384+
<goal>check</goal>
385+
</goals>
386+
<configuration>
387+
<configLocation>checkstyle.xml</configLocation>
388+
<headerLocation>rule-set-hdr.txt</headerLocation>
389+
<encoding>UTF-8</encoding>
390+
<consoleOutput>true</consoleOutput>
391+
<failsOnError>true</failsOnError>
392+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
393+
<linkXRef>false</linkXRef>
394+
</configuration>
395+
</execution>
396+
</executions>
397+
</plugin>
375398
<plugin>
376399
<groupId>org.basepom.maven</groupId>
377400
<artifactId>duplicate-finder-maven-plugin</artifactId>

rule-set-hdr.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright 2016 The LmdbJava Project, http://lmdbjava.org/
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/

src/main/java/org/lmdbjava/ByteBufferProxy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ protected void out(final ByteBuffer buffer, final Pointer ptr,
205205
}
206206
}
207207

208-
static abstract class AbstractByteBufferProxy extends BufferProxy<ByteBuffer> {
208+
abstract static class AbstractByteBufferProxy extends BufferProxy<ByteBuffer> {
209209

210210
/**
211211
* A thread-safe pool for a given length. If the buffer found is valid (ie

src/main/java/org/lmdbjava/Library.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private static String extract(final String name) {
117117
private Library() {
118118
}
119119

120-
@SuppressWarnings("all")
120+
@SuppressWarnings("checkstyle:typename")
121121
public static final class MDB_envinfo extends Struct {
122122

123123
public final Pointer f0_me_mapaddr;
@@ -127,7 +127,7 @@ public static final class MDB_envinfo extends Struct {
127127
public final u_int32_t f4_me_maxreaders;
128128
public final u_int32_t f5_me_numreaders;
129129

130-
public MDB_envinfo(jnr.ffi.Runtime runtime) {
130+
MDB_envinfo(final jnr.ffi.Runtime runtime) {
131131
super(runtime);
132132
this.f0_me_mapaddr = new Pointer();
133133
this.f1_me_mapsize = new size_t();
@@ -138,7 +138,7 @@ public MDB_envinfo(jnr.ffi.Runtime runtime) {
138138
}
139139
}
140140

141-
@SuppressWarnings("all")
141+
@SuppressWarnings("checkstyle:typename")
142142
public static final class MDB_stat extends Struct {
143143

144144
public final u_int32_t f0_ms_psize;
@@ -148,7 +148,7 @@ public static final class MDB_stat extends Struct {
148148
public final size_t f4_ms_overflow_pages;
149149
public final size_t f5_ms_entries;
150150

151-
public MDB_stat(jnr.ffi.Runtime runtime) {
151+
MDB_stat(final jnr.ffi.Runtime runtime) {
152152
super(runtime);
153153
this.f0_ms_psize = new u_int32_t();
154154
this.f1_ms_depth = new u_int32_t();
@@ -159,7 +159,7 @@ public MDB_stat(jnr.ffi.Runtime runtime) {
159159
}
160160
}
161161

162-
@SuppressWarnings("all")
162+
@SuppressWarnings({"checkstyle:methodname", "PMD.MethodNamingConventions"})
163163
public interface Lmdb {
164164

165165
void mdb_cursor_close(@In Pointer cursor);

src/main/java/org/lmdbjava/Txn.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright 2016 The LmdbJava Project, http://lmdbjava.org/
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package org.lmdbjava;
217

318
import static jnr.ffi.Memory.allocateDirect;

src/main/java/org/lmdbjava/UnsafeAccess.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2016 The LmdbJava Project, http://lmdbjava.org/.
2+
* Copyright 2016 The LmdbJava Project, http://lmdbjava.org/
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,

0 commit comments

Comments
 (0)