From a9ae14415b7fe5041fd0267859667f3eccc403d4 Mon Sep 17 00:00:00 2001 From: Justin Lee Date: Fri, 20 Sep 2013 12:24:41 -0400 Subject: [PATCH] code style updates --- build.gradle | 33 +++++- config/checkstyle-lite.xml | 152 ++++++++++++++++++++++++ config/checkstyle.xml | 183 ++++++++++++++++++++++++++++ config/clirr-exclude.yml | 211 +++++++++++++++++++++++++++++++++ config/codenarc/codenarc.xml | 64 ++++++++++ config/findbugs-exclude.xml | 51 ++++++++ gradle/maven-deployment.gradle | 2 +- 7 files changed, 694 insertions(+), 2 deletions(-) create mode 100644 config/checkstyle-lite.xml create mode 100644 config/checkstyle.xml create mode 100644 config/clirr-exclude.yml create mode 100644 config/codenarc/codenarc.xml create mode 100644 config/findbugs-exclude.xml diff --git a/build.gradle b/build.gradle index 41180578333..ed7158e240a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +def configDir = new File(rootDir, 'config') + task wrapper(type: Wrapper) { gradleVersion = '1.7' } @@ -5,6 +7,8 @@ task wrapper(type: Wrapper) { configure(subprojects) { apply plugin: 'java' apply plugin: 'idea' + apply plugin: 'checkstyle' + apply plugin: 'findbugs' group = 'org.mongodb.morphia' version = '0.106-SNAPSHOT' @@ -34,6 +38,29 @@ configure(subprojects) { options.compilerArgs << "-Xlint:unchecked" } } + + project.ext.buildingWith = { n -> project.hasProperty(n) && project.property(n).toBoolean() + } + + /* Code quality */ + checkstyle { + configFile = new File("$configDir/checkstyle.xml") + } + + findbugs { excludeFilter = new File("$configDir/findbugs-exclude.xml") } + + tasks.withType(FindBugs) { + reports { + xml.enabled = project.buildingWith('xmlReports.enabled') + html.enabled = !project.buildingWith('xmlReports.enabled') + } + } + + javadoc { + options.author = true + options.version = true + options.links 'http://docs.oracle.com/javase/7/docs/api/' + } } project(':morphia') { @@ -83,4 +110,8 @@ project(':gwt') { java { srcDirs = [] } } } -} \ No newline at end of file +} + +apply from: 'gradle/ide-settings.gradle' +apply from: 'gradle/maven-deployment.gradle' +//apply from: 'gradle/osgi-compatibility.gradle' \ No newline at end of file diff --git a/config/checkstyle-lite.xml b/config/checkstyle-lite.xml new file mode 100644 index 00000000000..c1c85429c76 --- /dev/null +++ b/config/checkstyle-lite.xml @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/checkstyle.xml b/config/checkstyle.xml new file mode 100644 index 00000000000..82ccd615adc --- /dev/null +++ b/config/checkstyle.xml @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/clirr-exclude.yml b/config/clirr-exclude.yml new file mode 100644 index 00000000000..c659b274572 --- /dev/null +++ b/config/clirr-exclude.yml @@ -0,0 +1,211 @@ +--- +differenceTypes: +- 10000 # (Class format version increased): className, from, to (class format version numbers, NOT expressions) +- 8000 # (Class added): className +- 7011 # (Method Added): className, method +- 6006 # (field now final): className, field + +packages: +- org.mongodb + +classes: +- org.bson.util.Assertions # JAVA-874 Deprecating {com.mongodb,org.bson}.util classes +- org.bson.util.SimplePool # JAVA-874 +- org.bson.util.annotations.GuardedBy # JAVA-874 +- org.bson.util.annotations.Immutable # JAVA-874 +- org.bson.util.annotations.NotThreadSafe # JAVA-874 +- org.bson.util.annotations.ThreadSafe # JAVA-874 +- com.mongodb.util.Args # JAVA-874 +- com.mongodb.util.Base64Codec # JAVA-874 +- com.mongodb.util.FastStack # JAVA-874 +- com.mongodb.util.Hash # JAVA-874 +- com.mongodb.util.IdentitySet # JAVA-874 +- com.mongodb.util.MyAsserts # JAVA-874 +- com.mongodb.util.OptionMap # JAVA-874 +- com.mongodb.util.StringBuilderPool # JAVA-874 +- com.mongodb.util.StringParseUtil # JAVA-874 +- com.mongodb.util.ThreadUtil # JAVA-874 +- com.mongodb.util.TimeConstants # JAVA-874 +- com.mongodb.util.ThreadPool # JAVA-874 +- com.mongodb.util.UniqueList # JAVA-874 +- com.mongodb.util.WeakBag # JAVA-874 +- com.mongodb.util.management.jmx.JMXMBeanServer # JAVA-875 Deprecate com.mongodb.util.management JMX support mechanism +- com.mongodb.util.management.JMException # JAVA-875 +- com.mongodb.util.management.MBeanServer # JAVA-875 +- com.mongodb.util.management.MBeanServerFactory # JAVA-875 +- com.mongodb.util.management.NullMBeanServer # JAVA-875 +- com.mongodb.MongoConnectionPoolMXBean # JAVA-875 +- com.mongodb.Java5MongoConnectionPoolMBean # JAVA-875 +- com.mongodb.Java5MongoConnectionPool # JAVA-875 +- com.mongodb.util.ConnectionPoolStatisticsBean # JAVA-875 +- com.mongodb.InUseConnectionBean # JAVA-875 +- com.mongodb.tools.ConnectionPoolStat # JAVA-875 +- org.bson.LazyDBList # JAVA-877 Move org.bson.LazyDBList to com.mongodb package +- com.mongodb.io.ByteStream # JAVA-893 Deprecate classes that will be excluded from 3.x (Generic) +- org.bson.io.PoolOutputBuffer # JAVA-893 +- com.mongodb.io.ByteBufferFactory # JAVA-893 +- com.mongodb.io.ByteBufferFactory$SimpleHeapByteBufferFactory # JAVA-893 +- com.mongodb.ReadPreference$TaggedReadPreference # JAVA-893 +- com.mongodb.io.ByteBufferHolder # JAVA-893 +- com.mongodb.io.ByteBufferFactory # JAVA-893 +- com.mongodb.io.ByteBufferInputStream # JAVA-893 +- com.mongodb.RawDBObject # JAVA-893 +- org.bson.NewBSONDecoder # JAVA-893 +- org.bson.BSONLazyDecoder # JAVA-893 +- com.mongodb.io.ByteBufferOutputStream # JAVA-893 +- com.mongodb.DBPort # JAVA-893 +- com.mongodb.DBPortPool # JAVA-893 +- com.mongodb.ReadPreference.TaggedReadPreference # JAVA-893 +- com.mongodb.MongoOptions # JAVA-893 +- com.mongodb.util.MyAsserts.MyAssert # JAVA-893 +- com.mongodb.DBPointer # JAVA-893 +- org.bson.BasicBSONDecoder$BSONInput # JAVA-895 Fix-up org.bson.BasicBSONDecoder +- com.mongodb.DBPortPool$ConnectionWaitTimeOut # JAVA-896 Deprecate exceptions nested under DBPortPool and MongoException and provide alternatives +- com.mongodb.DBPortPool$SemaphoresOut # JAVA-896 +- com.mongodb.DBPortPool$NoMoreConnection # JAVA-896 +- com.mongodb.MongoException$Network # JAVA-896 +- com.mongodb.MongoException$CursorNotFound # JAVA-896 +- com.mongodb.DBConnector # JAVA-897 Deprecate com.mongodb.{DBConnector, DBTCPConnector, DBApiLayer} and corresponding methods +- com.mongodb.DBTCPConnector # JAVA-897 +- com.mongodb.DBApiLayer # JAVA-897 +- org.bson.KeyCachingLazyBSONObject # JAVA-901 Cleanup org.bson.Lazy* +- org.bson.LazyBSONObject$LazyBSONKeySet # JAVA-901 +- com.mongodb.util.MyAsserts$MyAssert +- com.mongodb.util.SimplePool + +members: + com.mongodb.gridfs.GridFS: + - _bucketName # JAVA-924 Deprecate protected fields in com.mongodb.gridfs.{GridFS,GridFSFile} + - _chunkCollection # JAVA-924 + - _db # JAVA-924 + - _filesCollection # JAVA-924 + - _fix(java.lang.Object) # JAVA-924 + + com.mongodb.gridfs.GridFSFile: + - _fs # JAVA-924 + + com.mongodb.Mongo: + - getMongoOptions() # JAVA-882 Cleanup com.mongodb.Mongo + - getMinorVersion() # JAVA-882 + - getMajorVersion() # JAVA-882 + - debugString() # JAVA-882 + - connect(com.mongodb.DBAddress) # JAVA-882 + - getConnector() # JAVA-897 Deprecate com.mongodb.{DBConnector, DBTCPConnector, DBApiLayer} and corresponding methods + - MAJOR_VERSION + - MINOR_VERSION + + com.mongodb.DB: + - authenticateCommand(java.lang.String,char[]) # JAVA-838: Deprecate DB.authenticate + - authenticate(java.lang.String,char[]) # JAVA-838 + - isAuthenticated() # JAVA-838 + - setReadOnly(java.lang.Boolean) # JAVA-878 Deprecate DB.setReadOnly() + - _readOnly # JAVA-878 + + com.mongodb.DBCollection: + - checkReadOnly(boolean) # JAVA-878 + - _fullName # JAVA-881 Fix up com.mongodb.DBCollection + - _hintFields # JAVA-881 + - _name # JAVA-881 + - _objectClass # JAVA-881 + - _checkObject(com.mongodb.DBObject,boolean,boolean) # JAVA-881 + - genIndexName(com.mongodb.DBObject) # JAVA-881 + + org.bson.types.ObjectId: # JAVA-839: Fix up ObjectId API + - ObjectId(java.util.Date,int,int) # JAVA-839 + - ObjectId(java.lang.String,boolean) # JAVA-839 + - ObjectId(int,int,int) # JAVA-839 + - toStringMongod() # JAVA-839 + - toStringBabble() # JAVA-839 + - babbleToMongod(java.lang.String) # JAVA-839 + - getTimeSecond() # JAVA-839 + - getMachine() # JAVA-839 + - getInc() # JAVA-839 + - getGenMachineId() # JAVA-839 + - getCurrentInc() # JAVA-839 + - getTime() # JAVA-839 + - isNew() # JAVA-839 + - notNew() # JAVA-839 + - massageToObjectId(java.lang.Object) # JAVA-839 + - _flip(int) # JAVA-839 + - _inc() # JAVA-839 + - _machine() # JAVA-839 + - _time() # JAVA-839 + + com.mongodb.WriteResult: + - getLastError(com.mongodb.WriteConcern) # JAVA-900 + + com.mongodb.WriteConcern: # JAVA-893 Deprecate classes that will be excluded from 3.x (Generic) + - setWObject(java.lang.Object) # JAVA-893 + - continueOnErrorForInsert(boolean) # JAVA-939 + - getContinueOnErrorForInsert() # JAVA-939 + + + org.bson.io.OutputBuffer: # JAVA-880 Fix up org.bson.io.{OutputBuffer, BasicOutputBuffer} + - asString() # JAVA-880 + - asString(java.lang.String) # JAVA-880 + - pipe(java.io.DataOutput) # JAVA-880 + - seekEnd() # JAVA-880 + - seekStart() # JAVA-880 + - setPosition(int) # JAVA-880 + - md5() # JAVA-880 + - hex() # JAVA-880 + - writeInt(int,int) # JAVA-880 + - writeIntBE(int) # JAVA-880 + + org.bson.io.BasicOutputBuffer: + - asString() # JAVA-880 + - asString(java.lang.String) # JAVA-880 + - pipe(java.io.DataOutput) # JAVA-880 + - seekEnd() # JAVA-880 + - seekStart() # JAVA-880 + - setPosition(int) # JAVA-880 + + org.bson.BSON: + - _utf8 # JAVA-893 Deprecate classes that will be excluded from 3.x (Generic) + + org.bson.BasicBSONEncoder: + - _buf # JAVA-894 Fix-up org.bson.BasicBSONEncoder + - writeCString(java.lang.String) # JAVA-894 + - writeInt(int) # JAVA-894 + - writeLong(long) # JAVA-894 + - _put(byte,java.lang.String) # JAVA-894 + - _put(java.lang.String) # JAVA-894 + - _putValueString(java.lang.String) # JAVA-894 + - handleSpecialObjects(java.lang.String,org.bson.BSONObject) # JAVA-894 + + com.mongodb.DefaultDBEncoder: + - putDBPointer(java.lang.String,java.lang.String,org.bson.types.ObjectId) + + org.bson.BasicBSONDecoder: + - _callback # JAVA-895 Fix-up org.bson.BasicBSONDecoder + - _in # JAVA-895 Fix-up org.bson.BasicBSONDecoder + - _len # JAVA-895 Fix-up org.bson.BasicBSONDecoder + - _pos # JAVA-895 Fix-up org.bson.BasicBSONDecoder + - _binary(java.lang.String) # JAVA-895 Fix-up org.bson.BasicBSONDecoder + + org.bson.LazyBSONObject: + - getElementBSONSize(int) # JAVA-901 Cleanup org.bson.Lazy* + - getElementType(int) # JAVA-901 + - getElementValue(org.bson.LazyBSONObject$ElementRecord) # JAVA-901 + - isElementEmpty(int) # JAVA-901 + - sizeCString(int) # JAVA-901 + - _callback # JAVA-901 + - _doc_start_offset # JAVA-901 + - _input # JAVA-901 + + org.bson.LazyBSONCallback: + - setRootObject(java.lang.Object) # JAVA-901 + + com.mongodb.AggregationOutput: + - _commandResult # JAVA-925 Deprecate protected fields in com.mongodb.AggregationOutput + - _cmd # JAVA-925 + - _resultSet + + com.mongodb.ReadPreference: + - withTags(java.util.Map) # old ones + - withTags(com.mongodb.DBObject) # old ones + + com.mongodb.QueryOperators: + - QueryOperators() # JAVA-893 Deprecate classes that will be excluded from 3.x (Generic) + + diff --git a/config/codenarc/codenarc.xml b/config/codenarc/codenarc.xml new file mode 100644 index 00000000000..a8ff68377ea --- /dev/null +++ b/config/codenarc/codenarc.xml @@ -0,0 +1,64 @@ + + + MongoDB Java driver rule set + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/findbugs-exclude.xml b/config/findbugs-exclude.xml new file mode 100644 index 00000000000..7e8105fe4c2 --- /dev/null +++ b/config/findbugs-exclude.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gradle/maven-deployment.gradle b/gradle/maven-deployment.gradle index 5303df16cc7..6734c9e382c 100644 --- a/gradle/maven-deployment.gradle +++ b/gradle/maven-deployment.gradle @@ -14,7 +14,7 @@ * limitations under the License. */ -configure { +configure(subprojects) { apply plugin: 'maven' apply plugin: 'signing'