regular maintenance

Improve code quality after Codacy.com analysis.

Site: https://app.codacy.com
This commit is contained in:
Fabio Lima 2021-10-02 09:31:19 -03:00
parent 11dd761d76
commit e83a2fcf82
3 changed files with 125 additions and 128 deletions

View File

@ -20,20 +20,20 @@ Now you call `UlidFactory.newInstance()` and it's variants to get a new `UlidFac
### Added ### Added
- Added `UlidFactory.newInstance()` - Added `UlidFactory.newInstance()`
- Added `UlidFactory.newInstance(Random)` - Added `UlidFactory.newInstance(Random)`
- Added `UlidFactory.newInstance(Supplier<byte[]>)` - Added `UlidFactory.newInstance(Supplier<byte[]>)`
- Added `UlidFactory.newMonotonicInstance()` - Added `UlidFactory.newMonotonicInstance()`
- Added `UlidFactory.newMonotonicInstance(Random)` - Added `UlidFactory.newMonotonicInstance(Random)`
- Added `UlidFactory.newMonotonicInstance(Supplier<byte[]>)` - Added `UlidFactory.newMonotonicInstance(Supplier<byte[]>)`
- Added benchmark code to compare ULID with UUID - Added benchmark code to compare ULID with UUID
### Removed ### Removed
- Removed `DefaultFactory` - Removed `DefaultFactory`
- Removed `MonotonicFactory` - Removed `MonotonicFactory`
- Removed `Ulid.toUpperCase()` - Removed `Ulid.toUpperCase()`
- Removed `RandomGenerator` - Removed `RandomGenerator`
## [3.2.0] - 2021-07-17 ## [3.2.0] - 2021-07-17
@ -41,7 +41,7 @@ Simplified the use of `UlidFactory` with other random generators.
### Added ### Added
- Added constructors in `UlidFactory` for random generators. - Added constructors in `UlidFactory` for random generators.
## [3.1.1] - 2021-07-17 ## [3.1.1] - 2021-07-17
@ -49,7 +49,7 @@ Creates a module name be used in Java 9+.
### Added ### Added
- Added module name for Java 9+ - Added module name for Java 9+
## [3.1.0] - 2021-02-13 ## [3.1.0] - 2021-02-13
@ -57,21 +57,21 @@ Adds static methods for extracting information from ULIDs.
### Added ### Added
- Added `CHANGELOG.md` - Added `CHANGELOG.md`
- Added static method `Ulid.getInstant(String)` - Added static method `Ulid.getInstant(String)`
- Added static method `Ulid.getTime(String)` - Added static method `Ulid.getTime(String)`
- Added static method `Ulid.getRandom(String)` - Added static method `Ulid.getRandom(String)`
### Changed ### Changed
- Updated `README.md` - Updated `README.md`
- Updated test cases - Updated test cases
## [3.0.1] - 2021-01-30 ## [3.0.1] - 2021-01-30
### Changed ### Changed
- Renamed subpackage `creator` to `factory` - Renamed subpackage `creator` to `factory`
## [3.0.0] - 2021-01-30 ## [3.0.0] - 2021-01-30
@ -81,46 +81,46 @@ Now the `ulid-creator` can generate two types of ULID: default (non-monotonic) a
### Added ### Added
- Added class `Ulid` - Added class `Ulid`
- Added abstract class `UlidFactory` - Added abstract class `UlidFactory`
- Added class `DefaultUlidFactory` - Added class `DefaultUlidFactory`
- Added class `MonotonicUlidFactory` - Added class `MonotonicUlidFactory`
- Added functional interface `RandomGenerator` - Added functional interface `RandomGenerator`
- Added class `DefaultRandomGenerator` - Added class `DefaultRandomGenerator`
- Added static method `UlidCreator.getUlid(): Ulid` - Added static method `UlidCreator.getUlid(): Ulid`
- Added static method `UlidCreator.getUlid(long): Ulid` - Added static method `UlidCreator.getUlid(long): Ulid`
- Added static method `UlidCreator.getMonotonicUlid(): Ulid` - Added static method `UlidCreator.getMonotonicUlid(): Ulid`
- Added static method `UlidCreator.getMonotonicUlid(long): Ulid` - Added static method `UlidCreator.getMonotonicUlid(long): Ulid`
- Added static method `UlidCreator.getDefaultFactory(): UlidFactory` - Added static method `UlidCreator.getDefaultFactory(): UlidFactory`
- Added static method `UlidCreator.getMonotonicFactory(): UlidFactory` - Added static method `UlidCreator.getMonotonicFactory(): UlidFactory`
### Changed ### Changed
- Rewrote `UlidCreator` - Rewrote `UlidCreator`
- Rewrote all `README.md` - Rewrote all `README.md`
- Rewrote all test cases - Rewrote all test cases
### Removed ### Removed
- Removed class `UlidStruct`, replaced by `Ulid` - Removed class `UlidStruct`, replaced by `Ulid`
- Removed class `UlidUtil`, use`Ulid` instead - Removed class `UlidUtil`, use`Ulid` instead
- Removed class `UlidConverter`, use `Ulid` instead - Removed class `UlidConverter`, use `Ulid` instead
- Removed class `UlidValidator`, use`Ulid` instead - Removed class `UlidValidator`, use`Ulid` instead
- Removed class `UlidSpecCreator`, replaced by `UlidFactory` - Removed class `UlidSpecCreator`, replaced by `UlidFactory`
- Removed class `InvalidUlidException`, replaced by `IllegalArgumentException` - Removed class `InvalidUlidException`, replaced by `IllegalArgumentException`
- Removed interface `RandomStrategy`, replaced by `RandomGenerator` - Removed interface `RandomStrategy`, replaced by `RandomGenerator`
- Removed class `DefaultRandomStrategy`, replaced by `DefaultRandomGenerator` - Removed class `DefaultRandomStrategy`, replaced by `DefaultRandomGenerator`
- Removed class `OtherRandomStrategy` - Removed class `OtherRandomStrategy`
- Removed interface `TimestampStrategy` - Removed interface `TimestampStrategy`
- Removed class `DefaultTimestampStrategy` - Removed class `DefaultTimestampStrategy`
- Removed class `FixedTimestampStrategy` - Removed class `FixedTimestampStrategy`
- Removed static method `UlidCreator.fromString(String): UUID` - Removed static method `UlidCreator.fromString(String): UUID`
- Removed static method `UlidCreator.toString(UUID): String` - Removed static method `UlidCreator.toString(UUID): String`
- Removed static method `UlidCreator.getUlid(): UUID` - Removed static method `UlidCreator.getUlid(): UUID`
- Removed static method `UlidCreator.getUlid4(): UUID` - Removed static method `UlidCreator.getUlid4(): UUID`
- Removed static method `UlidCreator.getUlidString(): String` - Removed static method `UlidCreator.getUlidString(): String`
- Removed static method `UlidCreator.getUlidString4(): String` - Removed static method `UlidCreator.getUlidString4(): String`
- Removed static method `UlidCreator.getUlidSpecCreator(): UlidSpecCreator` - Removed static method `UlidCreator.getUlidSpecCreator(): UlidSpecCreator`
## [2.3.3] - 2020-11-16 ## [2.3.3] - 2020-11-16
@ -128,16 +128,16 @@ Optimization and housekeeping.
### Added ### Added
- Added test cases - Added test cases
### Changed ### Changed
- Optimized `UlidSpecCreator` - Optimized `UlidSpecCreator`
- Updated `README.md` - Updated `README.md`
### Removed ### Removed
- Removed unused code - Removed unused code
## [2.3.2] - 2020-11-09 ## [2.3.2] - 2020-11-09
@ -145,7 +145,7 @@ Only Optimization.
### Changed ### Changed
- Optimized `UlidValidator` - Optimized `UlidValidator`
## [2.3.1] - 2020-11-08 ## [2.3.1] - 2020-11-08
@ -153,13 +153,13 @@ Added static methods for extracting Unix time.
### Added ### Added
- Added static method `UlidUtil.extractUnixMilliseconds(UUID)` - Added static method `UlidUtil.extractUnixMilliseconds(UUID)`
- Added static method `UlidUtil.extractUnixMilliseconds(String)` - Added static method `UlidUtil.extractUnixMilliseconds(String)`
### Changed ### Changed
- Moved UUID v4 generation to `UlidStruct` - Moved UUID v4 generation to `UlidStruct`
- Updated test cases - Updated test cases
## [2.3.0] - 2020-11-08 ## [2.3.0] - 2020-11-08
@ -167,15 +167,15 @@ Now it can generate UUIDs and ULIDs compatible with RFC-4122 UUID v4.
### Added ### Added
- Added static method `UlidCreator.getUlid4()` - Added static method `UlidCreator.getUlid4()`
- Added static method `UlidCreator.getUlidString4()` - Added static method `UlidCreator.getUlidString4()`
- Added method `UlidSpecCreator.create4()` - Added method `UlidSpecCreator.create4()`
- Added method `UlidSpecCreator.createString4()` - Added method `UlidSpecCreator.createString4()`
### Changed ### Changed
- Updated `README.md` - Updated `README.md`
- Updated test cases - Updated test cases
## [2.2.0] - 2020-11-08 ## [2.2.0] - 2020-11-08
@ -183,16 +183,16 @@ Now the generation of ULID in canonical string format is 2.5x faster than before
### Added ### Added
- Added `UlidStruct` for internal use - Added `UlidStruct` for internal use
- Added test cases - Added test cases
### Changed ### Changed
- Optimized `UlidSpecCreator` by using `UlidStruct` - Optimized `UlidSpecCreator` by using `UlidStruct`
- Optimized `UlidConverter` by using `UlidStruct` - Optimized `UlidConverter` by using `UlidStruct`
- Optimized `UlidValidator` - Optimized `UlidValidator`
- Updated `README.md` - Updated `README.md`
- Updated javadoc - Updated javadoc
## [2.1.0] - 2020-10-17 ## [2.1.0] - 2020-10-17
@ -200,13 +200,13 @@ Removed the overrun exception because it is extremely unlikely to occur
### Changed ### Changed
- Updated `README.md` - Updated `README.md`
- Updated test cases - Updated test cases
- Updated javadoc - Updated javadoc
### Removed ### Removed
- Removed `UlidCreatorException`, used in overruns - Removed `UlidCreatorException`, used in overruns
## [2.0.0] - 2020-07-04 ## [2.0.0] - 2020-07-04
@ -214,37 +214,37 @@ This version breaks compatibility.
### Added ### Added
- Added `RandomStrategy` - Added `RandomStrategy`
- Added `DefaultRandomStrategy` - Added `DefaultRandomStrategy`
- Added `OtherRandomStrategy` - Added `OtherRandomStrategy`
- Added test cases - Added test cases
### Changed ### Changed
- Changed `UlidCreator` - Changed `UlidCreator`
- Renamed `UlidBasedGuidCreator` to `UlidSpecCreator` - Renamed `UlidBasedGuidCreator` to `UlidSpecCreator`
- Changed JDK version from 11 to 8 for compatibility with Java 8 - Changed JDK version from 11 to 8 for compatibility with Java 8
- Optimized `UlidConverter.fromString(String)` - Optimized `UlidConverter.fromString(String)`
- Optimized `UlidConverter.toString(UUID)` - Optimized `UlidConverter.toString(UUID)`
- Optimized `UlidValidator.isValid(String)` - Optimized `UlidValidator.isValid(String)`
- Updated `README.md` - Updated `README.md`
- Updated `pom.xml` - Updated `pom.xml`
- Updated test cases - Updated test cases
- Updated javadoc - Updated javadoc
## [1.1.0] - 2020-04-18 ## [1.1.0] - 2020-04-18
### Changed ### Changed
- Renamed `GuidCreator` to `UlidBasedGuidCreator` - Renamed `GuidCreator` to `UlidBasedGuidCreator`
- Changed the overrun exception to be thrown when 2^80 requests occurs within the same msec - Changed the overrun exception to be thrown when 2^80 requests occurs within the same msec
- Updated `README.md` - Updated `README.md`
- Updated `pom.xml` - Updated `pom.xml`
- Updated test cases - Updated test cases
### Removed ### Removed
- Removed unused code - Removed unused code
## [1.0.0] - 2020-02-23 ## [1.0.0] - 2020-02-23
@ -252,23 +252,23 @@ Project created as an alternative Java implementation of [ULID spec](https://git
### Added ### Added
- Added `UlidCreator` - Added `UlidCreator`
- Added `GuidCreator` - Added `GuidCreator`
- Added `TimestampStrategy` - Added `TimestampStrategy`
- Added `DefaultTimestampStrategy` - Added `DefaultTimestampStrategy`
- Added `FixedTimestampStrategy` - Added `FixedTimestampStrategy`
- Added `XorshiftRandom` - Added `XorshiftRandom`
- Added `Xorshift128PlusRandom` - Added `Xorshift128PlusRandom`
- Added `Base32Util` - Added `Base32Util`
- Added `ByteUtil` - Added `ByteUtil`
- Added `FingerprintUtil` - Added `FingerprintUtil`
- Added `NetworkData` - Added `NetworkData`
- Added `UlidUtil` - Added `UlidUtil`
- Added `UlidCreatorException` - Added `UlidCreatorException`
- Added `README.md` - Added `README.md`
- Added `pom.xml` - Added `pom.xml`
- Added `LICENSE` - Added `LICENSE`
- Added test cases - Added test cases
[unreleased]: https://github.com/f4b6a3/ulid-creator/compare/ulid-creator-4.1.0...HEAD [unreleased]: https://github.com/f4b6a3/ulid-creator/compare/ulid-creator-4.1.0...HEAD
[4.1.0]: https://github.com/f4b6a3/ulid-creator/compare/ulid-creator-4.0.0...ulid-creator-4.1.0 [4.1.0]: https://github.com/f4b6a3/ulid-creator/compare/ulid-creator-4.0.0...ulid-creator-4.1.0

View File

@ -3,16 +3,16 @@
ARTIFACT_ID=ulid-creator ARTIFACT_ID=ulid-creator
# find the script folder # find the script folder
SCRIPT_DIR=`dirname "$0"` SCRIPT_DIR=$(dirname "$0")
# go to the parent folder # go to the parent folder
cd ${SCRIPT_DIR}/.. cd "${SCRIPT_DIR}/.."
# compile the parent project # compile the parent project
mvn clean install mvn clean install
# create a symbolic link to be imported to the maven repository # create a copy with the expected name
cp ${PWD}/target/${ARTIFACT_ID}-*-SNAPSHOT.jar ${PWD}/target/${ARTIFACT_ID}-0.0.1-BENCHMARK.jar cp "${PWD}/target/${ARTIFACT_ID}"-*-SNAPSHOT.jar "${PWD}/target/${ARTIFACT_ID}"-0.0.1-BENCHMARK.jar
# go to the benchmark folder # go to the benchmark folder
cd benchmark cd benchmark
@ -25,4 +25,3 @@ mvn clean install
# /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -jar target/benchmarks.jar # /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -jar target/benchmarks.jar
java -jar target/benchmarks.jar java -jar target/benchmarks.jar

View File

@ -92,12 +92,10 @@ public class UniquenessTest {
// Request a ULID // Request a ULID
Ulid ulid = factory.create(time); Ulid ulid = factory.create(time);
if (verbose) { if (verbose && (i % (max / 100) == 0)) {
if (i % (max / 100) == 0) { // Calculate and show progress
// Calculate and show progress progress = (int) ((i * 1.0 / max) * 100);
progress = (int) ((i * 1.0 / max) * 100); System.out.println(String.format("[Thread %06d] %s %s %s%%", id, ulid, i, (int) progress));
System.out.println(String.format("[Thread %06d] %s %s %s%%", id, ulid, i, (int) progress));
}
} }
synchronized (hashSet) { synchronized (hashSet) {
// Insert the value in cache, if it does not exist in it. // Insert the value in cache, if it does not exist in it.