Skip to content

Commit befe396

Browse files
committed
Maven static analysis plugins and required changes
(Checkstyle is still to be added)
1 parent 2590b26 commit befe396

31 files changed

+741
-622
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,16 @@ we can discuss what you have in mind.
1111

1212
## Priorities
1313

14-
All engineering decisions require trade-offs, which is why we have an ordered list of
14+
All engineering decisions require trade-offs, which is why we have an ordered list of
1515
[priorites](https://github.com/lmdbjava/lmdbjava/blob/master/src/main/java/org/lmdbjava/package-info.java).
1616
Please ensure your changes reflect those priorities.
1717

1818
## Style
1919

20-
Please use the current code as your style guide. Highlights:
21-
22-
* Add the copyright header to each file
23-
* Use `final`
24-
* Use `import static`
25-
* Keep methods short and clear
26-
* Exceptions extend `LmdbException` and are typically static inner classes
27-
* JavaDocs are needed for public types and methods
28-
* Test coverage is important (Travis and Coveralls run for every pull request)
20+
Please use the current code as your style guide and run `mvn clean verify`
21+
before submitting a pull request. This will execute Maven checks using PMD,
22+
FindBugs, Checkstyle, XML Formatting, classpath duplication, dependency usage,
23+
and dependency versioning plugins.
2924

3025
## Questions
3126

pom.xml

Lines changed: 219 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<name>Kristoffer Sjogren</name>
5656
<id>krisskross</id>
5757
<email>stoffe -at- gmail.com</email>
58-
<organization />
58+
<organization/>
5959
<url>http://stoffe.deephacks.org/</url>
6060
<timezone>+1</timezone>
6161
</developer>
@@ -103,13 +103,19 @@
103103
</dependency>
104104
<dependency>
105105
<groupId>org.hamcrest</groupId>
106-
<artifactId>hamcrest-all</artifactId>
106+
<artifactId>hamcrest-core</artifactId>
107+
<version>1.3</version>
108+
<scope>test</scope>
109+
</dependency>
110+
<dependency>
111+
<groupId>org.hamcrest</groupId>
112+
<artifactId>hamcrest-library</artifactId>
107113
<version>1.3</version>
108114
<scope>test</scope>
109115
</dependency>
110116
<dependency>
111117
<groupId>org.mockito</groupId>
112-
<artifactId>mockito-all</artifactId>
118+
<artifactId>mockito-core</artifactId>
113119
<version>1.10.19</version>
114120
<scope>test</scope>
115121
</dependency>
@@ -134,6 +140,27 @@
134140
</dependencies>
135141
<build>
136142
<plugins>
143+
<plugin>
144+
<artifactId>maven-shade-plugin</artifactId>
145+
<version>2.4.3</version>
146+
<executions>
147+
<execution>
148+
<phase>package</phase>
149+
<goals>
150+
<goal>shade</goal>
151+
</goals>
152+
<configuration>
153+
<artifactSet>
154+
<includes>
155+
<include>org.lmdbjava:lmdbjava-native-linux-x86_64</include>
156+
<include>org.lmdbjava:lmdbjava-native-windows-x86_64</include>
157+
<include>org.lmdbjava:lmdbjava-native-osx-x86_64</include>
158+
</includes>
159+
</artifactSet>
160+
</configuration>
161+
</execution>
162+
</executions>
163+
</plugin>
137164
<plugin>
138165
<groupId>org.jacoco</groupId>
139166
<artifactId>jacoco-maven-plugin</artifactId>
@@ -145,6 +172,35 @@
145172
<goal>prepare-agent</goal>
146173
</goals>
147174
</execution>
175+
<execution>
176+
<id>default-report</id>
177+
<phase>prepare-package</phase>
178+
<goals>
179+
<goal>report</goal>
180+
</goals>
181+
</execution>
182+
<execution>
183+
<id>default-check</id>
184+
<goals>
185+
<goal>check</goal>
186+
</goals>
187+
<configuration>
188+
<rules>
189+
<rule>
190+
<limits>
191+
<limit>
192+
<counter>LINE</counter>
193+
<minimum>0.95</minimum>
194+
</limit>
195+
<limit>
196+
<counter>COMPLEXITY</counter>
197+
<minimum>0.60</minimum>
198+
</limit>
199+
</limits>
200+
</rule>
201+
</rules>
202+
</configuration>
203+
</execution>
148204
</executions>
149205
<configuration>
150206
<excludes>
@@ -158,33 +214,6 @@
158214
<artifactId>coveralls-maven-plugin</artifactId>
159215
<version>4.2.0</version>
160216
</plugin>
161-
<plugin>
162-
<groupId>org.apache.maven.plugins</groupId>
163-
<artifactId>maven-release-plugin</artifactId>
164-
<version>2.5.3</version>
165-
</plugin>
166-
<plugin>
167-
<groupId>org.apache.maven.plugins</groupId>
168-
<artifactId>maven-shade-plugin</artifactId>
169-
<version>2.4.3</version>
170-
<executions>
171-
<execution>
172-
<phase>package</phase>
173-
<goals>
174-
<goal>shade</goal>
175-
</goals>
176-
<configuration>
177-
<artifactSet>
178-
<includes>
179-
<include>org.lmdbjava:lmdbjava-native-linux-x86_64</include>
180-
<include>org.lmdbjava:lmdbjava-native-windows-x86_64</include>
181-
<include>org.lmdbjava:lmdbjava-native-osx-x86_64</include>
182-
</includes>
183-
</artifactSet>
184-
</configuration>
185-
</execution>
186-
</executions>
187-
</plugin>
188217
<plugin>
189218
<groupId>au.com.acegi</groupId>
190219
<artifactId>xml-format-maven-plugin</artifactId>
@@ -226,6 +255,166 @@
226255
</execution>
227256
</executions>
228257
</plugin>
258+
<plugin>
259+
<artifactId>maven-release-plugin</artifactId>
260+
<version>2.5.3</version>
261+
</plugin>
262+
<plugin>
263+
<artifactId>maven-site-plugin</artifactId>
264+
<version>3.3</version>
265+
</plugin>
266+
<plugin>
267+
<artifactId>maven-resources-plugin</artifactId>
268+
<version>2.6</version>
269+
</plugin>
270+
<plugin>
271+
<artifactId>maven-compiler-plugin</artifactId>
272+
<version>3.1</version>
273+
</plugin>
274+
<plugin>
275+
<artifactId>maven-surefire-plugin</artifactId>
276+
<version>2.12.4</version>
277+
</plugin>
278+
<plugin>
279+
<artifactId>maven-jar-plugin</artifactId>
280+
<version>2.4</version>
281+
</plugin>
282+
<plugin>
283+
<artifactId>maven-clean-plugin</artifactId>
284+
<version>2.5</version>
285+
</plugin>
286+
<plugin>
287+
<artifactId>maven-install-plugin</artifactId>
288+
<version>2.4</version>
289+
</plugin>
290+
<plugin>
291+
<artifactId>maven-deploy-plugin</artifactId>
292+
<version>2.7</version>
293+
</plugin>
294+
<plugin>
295+
<artifactId>maven-dependency-plugin</artifactId>
296+
<version>2.10</version>
297+
<executions>
298+
<execution>
299+
<id>analyze</id>
300+
<goals>
301+
<goal>analyze-only</goal>
302+
</goals>
303+
</execution>
304+
</executions>
305+
<configuration>
306+
<failOnWarning>true</failOnWarning>
307+
<ignoredUnusedDeclaredDependencies>
308+
<ignoredUnusuedDeclaredDependency>org.mockito:mockito-core</ignoredUnusuedDeclaredDependency>
309+
<ignoredUnusuedDeclaredDependency>org.lmdbjava:lmdbjava-native-linux-x86_64</ignoredUnusuedDeclaredDependency>
310+
<ignoredUnusuedDeclaredDependency>org.lmdbjava:lmdbjava-native-windows-x86_64</ignoredUnusuedDeclaredDependency>
311+
<ignoredUnusuedDeclaredDependency>org.lmdbjava:lmdbjava-native-osx-x86_64</ignoredUnusuedDeclaredDependency>
312+
</ignoredUnusedDeclaredDependencies>
313+
</configuration>
314+
</plugin>
315+
<plugin>
316+
<artifactId>maven-enforcer-plugin</artifactId>
317+
<version>1.4.1</version>
318+
<executions>
319+
<execution>
320+
<id>enforce-versions</id>
321+
<goals>
322+
<goal>enforce</goal>
323+
</goals>
324+
</execution>
325+
</executions>
326+
<configuration>
327+
<rules>
328+
<requireJavaVersion>
329+
<version>[1.8.0,)</version>
330+
</requireJavaVersion>
331+
<requirePluginVersions/>
332+
<requireReleaseDeps/>
333+
</rules>
334+
</configuration>
335+
</plugin>
336+
<plugin>
337+
<artifactId>maven-pmd-plugin</artifactId>
338+
<version>3.6</version>
339+
<executions>
340+
<execution>
341+
<id>pmd-check</id>
342+
<phase>verify</phase>
343+
<goals>
344+
<goal>check</goal>
345+
<goal>cpd-check</goal>
346+
</goals>
347+
</execution>
348+
</executions>
349+
<configuration>
350+
<printFailingErrors>true</printFailingErrors>
351+
<includeTests>true</includeTests>
352+
<rulesets>
353+
<ruleset>${basedir}/rule-set-pmd.xml</ruleset>
354+
</rulesets>
355+
</configuration>
356+
</plugin>
357+
<plugin>
358+
<groupId>org.codehaus.mojo</groupId>
359+
<artifactId>findbugs-maven-plugin</artifactId>
360+
<version>3.0.3</version>
361+
<executions>
362+
<execution>
363+
<id>find-bugs</id>
364+
<phase>verify</phase>
365+
<goals>
366+
<goal>check</goal>
367+
</goals>
368+
</execution>
369+
</executions>
370+
<configuration>
371+
<failOnError>true</failOnError>
372+
<includeTests>true</includeTests>
373+
</configuration>
374+
</plugin>
375+
<plugin>
376+
<groupId>org.basepom.maven</groupId>
377+
<artifactId>duplicate-finder-maven-plugin</artifactId>
378+
<version>1.2.1</version>
379+
<executions>
380+
<execution>
381+
<id>enforce-no-duplicates</id>
382+
<phase>verify</phase>
383+
<goals>
384+
<goal>check</goal>
385+
</goals>
386+
</execution>
387+
</executions>
388+
<configuration>
389+
<printEqualFiles>true</printEqualFiles>
390+
<failBuildInCaseOfDifferentContentConflict>true</failBuildInCaseOfDifferentContentConflict>
391+
<failBuildInCaseOfEqualContentConflict>true</failBuildInCaseOfEqualContentConflict>
392+
<failBuildInCaseOfConflict>true</failBuildInCaseOfConflict>
393+
<ignoredResourcePatterns>
394+
<ignoredResourcePattern>.netbeans_automatic_build</ignoredResourcePattern>
395+
</ignoredResourcePatterns>
396+
</configuration>
397+
</plugin>
398+
<plugin>
399+
<groupId>org.codehaus.mojo</groupId>
400+
<artifactId>versions-maven-plugin</artifactId>
401+
<version>2.2</version>
402+
<executions>
403+
<execution>
404+
<id>report-new-dependencies</id>
405+
<phase>verify</phase>
406+
<goals>
407+
<goal>display-plugin-updates</goal>
408+
<goal>display-parent-updates</goal>
409+
<goal>display-property-updates</goal>
410+
<goal>display-dependency-updates</goal>
411+
</goals>
412+
</execution>
413+
</executions>
414+
<configuration>
415+
<rulesUri>file://${basedir}/rule-set-ver.xml</rulesUri>
416+
</configuration>
417+
</plugin>
229418
</plugins>
230419
</build>
231420
<profiles>

rule-set-pmd.xml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="mybraces" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
3+
<rule ref="rulesets/java/basic.xml"/>
4+
<rule ref="rulesets/java/braces.xml"/>
5+
<rule ref="rulesets/java/clone.xml"/>
6+
<rule ref="rulesets/java/codesize.xml">
7+
<exclude name="ExcessivePublicCount"/>
8+
<exclude name="TooManyMethods"/>
9+
</rule>
10+
<rule ref="rulesets/java/controversial.xml/UnnecessaryConstructor"/>
11+
<rule ref="rulesets/java/controversial.xml/SuspiciousOctalEscape"/>
12+
<rule ref="rulesets/java/controversial.xml/CallSuperInConstructor"/>
13+
<rule ref="rulesets/java/controversial.xml/UnnecessaryParentheses"/>
14+
<rule ref="rulesets/java/controversial.xml/AvoidUsingShortType"/>
15+
<rule ref="rulesets/java/controversial.xml/DoNotCallGarbageCollectionExplicitly"/>
16+
<rule ref="rulesets/java/controversial.xml/AvoidLiteralsInIfCondition"/>
17+
<rule ref="rulesets/java/coupling.xml/LooseCoupling"/>
18+
<rule ref="rulesets/java/design.xml">
19+
<exclude name="FieldDeclarationsShouldBeAtStartOfClass"/>
20+
</rule>
21+
<rule ref="rulesets/java/finalizers.xml"/>
22+
<rule ref="rulesets/java/imports.xml">
23+
<exclude name="TooManyStaticImports"/>
24+
</rule>
25+
<rule ref="rulesets/java/j2ee.xml/UseProperClassLoader"/>
26+
<rule ref="rulesets/java/j2ee.xml/DoNotCallSystemExit"/>
27+
<rule ref="rulesets/java/j2ee.xml/DoNotUseThreads"/>
28+
<rule ref="rulesets/java/migrating.xml"/>
29+
<rule ref="rulesets/java/naming.xml">
30+
<exclude name="ShortClassName"/>
31+
<exclude name="ShortMethodName"/>
32+
<exclude name="ShortVariable"/>
33+
<exclude name="LongVariable"/>
34+
</rule>
35+
<rule ref="rulesets/java/optimizations.xml"/>
36+
<rule ref="rulesets/java/strictexception.xml"/>
37+
<rule ref="rulesets/java/strings.xml">
38+
<exclude name="AvoidDuplicateLiterals"/>
39+
</rule>
40+
<rule ref="rulesets/java/strings.xml/AvoidDuplicateLiterals">
41+
<properties>
42+
<property name="skipAnnotations" value="true"/>
43+
</properties>
44+
</rule>
45+
<rule ref="rulesets/java/sunsecure.xml"/>
46+
<rule ref="rulesets/java/unusedcode.xml"/>
47+
<rule ref="rulesets/java/typeresolution.xml"/>
48+
</ruleset>

rule-set-ver.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset xmlns="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" comparisonMethod="maven" xsi:schemaLocation="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0 http://mojo.codehaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd">
3+
<ignoreVersions>
4+
<ignoreVersion type="regex">.*Alpha.*</ignoreVersion>
5+
<ignoreVersion type="regex">.*beta.*</ignoreVersion>
6+
<ignoreVersion type="regex">.*atlassian.*</ignoreVersion>
7+
</ignoreVersions>
8+
</ruleset>

src/main/java/org/lmdbjava/BufferProxy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
* @param <T> buffer type
2929
*/
30-
public abstract class BufferProxy<T> {
30+
public abstract class BufferProxy<T> { // NOPMD
3131

3232
/**
3333
* Size of a <code>MDB_val</code> pointer in bytes.

0 commit comments

Comments
 (0)