NullPointerException creating scaladoc (#115)

* [domain] Drop use of Lenses macro and only create used lenses

* [core] Drop use of Lenses macro and only create used lenses

* [sbt] drop paradise plugin

* [changelog] updated
This commit is contained in:
Paul Campbell 2019-07-19 23:30:20 +01:00 committed by GitHub
parent c33fa05d19
commit 32ef58ff11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 48 additions and 90 deletions

View file

@ -6,6 +6,18 @@ The format is based on [[https://keepachangelog.com/en/1.0.0/][Keep a Changelog]
[[https://semver.org/spec/v2.0.0.html][Semantic Versioning]]. [[https://semver.org/spec/v2.0.0.html][Semantic Versioning]].
* [0.7.2] - 2019-07-19
** Changed
- Apply ~scalafmt~ (#108)
- Uses Lenses (#113)
** Fixed
- Creates incorrect MD5 hash for some files (#103)
- NullPointerException creating scaladoc (#115)
* [0.7.1] - 2019-07-15 * [0.7.1] - 2019-07-15
** Changed ** Changed

View file

@ -26,9 +26,6 @@ val commonSettings = Seq(
"-language:postfixOps", "-language:postfixOps",
"-language:higherKinds", "-language:higherKinds",
"-Ypartial-unification"), "-Ypartial-unification"),
addCompilerPlugin(
"org.scalameta" % "paradise" % "3.0.0-M11" cross CrossVersion.full
),
test in assembly := {} test in assembly := {}
) )

View file

@ -1,6 +1,5 @@
package net.kemitix.thorp.core package net.kemitix.thorp.core
import monocle.macros.Lenses
import net.kemitix.thorp.domain.{Bucket, LocalFile, MD5Hash, RemoteKey} import net.kemitix.thorp.domain.{Bucket, LocalFile, MD5Hash, RemoteKey}
sealed trait Action { sealed trait Action {
@ -9,21 +8,18 @@ sealed trait Action {
} }
object Action { object Action {
@Lenses
final case class DoNothing( final case class DoNothing(
bucket: Bucket, bucket: Bucket,
remoteKey: RemoteKey, remoteKey: RemoteKey,
size: Long size: Long
) extends Action ) extends Action
@Lenses
final case class ToUpload( final case class ToUpload(
bucket: Bucket, bucket: Bucket,
localFile: LocalFile, localFile: LocalFile,
size: Long size: Long
) extends Action ) extends Action
@Lenses
final case class ToCopy( final case class ToCopy(
bucket: Bucket, bucket: Bucket,
sourceKey: RemoteKey, sourceKey: RemoteKey,
@ -32,7 +28,6 @@ object Action {
size: Long size: Long
) extends Action ) extends Action
@Lenses
final case class ToDelete( final case class ToDelete(
bucket: Bucket, bucket: Bucket,
remoteKey: RemoteKey, remoteKey: RemoteKey,

View file

@ -2,7 +2,6 @@ package net.kemitix.thorp.core
import java.nio.file.Path import java.nio.file.Path
import monocle.macros.Lenses
import net.kemitix.thorp.domain import net.kemitix.thorp.domain
import net.kemitix.thorp.domain.{Config, RemoteKey} import net.kemitix.thorp.domain.{Config, RemoteKey}
import net.kemitix.thorp.domain.Config._ import net.kemitix.thorp.domain.Config._
@ -13,13 +12,11 @@ sealed trait ConfigOption {
object ConfigOption { object ConfigOption {
@Lenses
case class Source(path: Path) extends ConfigOption { case class Source(path: Path) extends ConfigOption {
override def update(config: Config): Config = override def update(config: Config): Config =
sources.modify(_ ++ path)(config) sources.modify(_ ++ path)(config)
} }
@Lenses
case class Bucket(name: String) extends ConfigOption { case class Bucket(name: String) extends ConfigOption {
override def update(config: Config): Config = override def update(config: Config): Config =
if (config.bucket.name.isEmpty) if (config.bucket.name.isEmpty)
@ -28,7 +25,6 @@ object ConfigOption {
config config
} }
@Lenses
case class Prefix(path: String) extends ConfigOption { case class Prefix(path: String) extends ConfigOption {
override def update(config: Config): Config = override def update(config: Config): Config =
if (config.prefix.key.isEmpty) if (config.prefix.key.isEmpty)
@ -37,19 +33,16 @@ object ConfigOption {
config config
} }
@Lenses
case class Include(pattern: String) extends ConfigOption { case class Include(pattern: String) extends ConfigOption {
override def update(config: Config): Config = override def update(config: Config): Config =
filters.modify(domain.Filter.Include(pattern) :: _)(config) filters.modify(domain.Filter.Include(pattern) :: _)(config)
} }
@Lenses
case class Exclude(pattern: String) extends ConfigOption { case class Exclude(pattern: String) extends ConfigOption {
override def update(config: Config): Config = override def update(config: Config): Config =
filters.modify(domain.Filter.Exclude(pattern) :: _)(config) filters.modify(domain.Filter.Exclude(pattern) :: _)(config)
} }
@Lenses
case class Debug() extends ConfigOption { case class Debug() extends ConfigOption {
override def update(config: Config): Config = override def update(config: Config): Config =
debug.set(true)(config) debug.set(true)(config)

View file

@ -1,9 +1,9 @@
package net.kemitix.thorp.core package net.kemitix.thorp.core
import cats.Semigroup import cats.Semigroup
import monocle.macros.Lenses import monocle.Lens
import monocle.macros.GenLens
@Lenses
case class ConfigOptions( case class ConfigOptions(
options: List[ConfigOption] = List() options: List[ConfigOption] = List()
) extends Semigroup[ConfigOptions] { ) extends Semigroup[ConfigOptions] {
@ -24,3 +24,8 @@ case class ConfigOptions(
options contains elem options contains elem
} }
object ConfigOptions {
val options: Lens[ConfigOptions, List[ConfigOption]] =
GenLens[ConfigOptions](_.options)
}

View file

@ -1,11 +1,18 @@
package net.kemitix.thorp.core package net.kemitix.thorp.core
import monocle.macros.Lenses import monocle.Lens
import monocle.macros.GenLens
@Lenses
final case class Counters( final case class Counters(
uploaded: Int = 0, uploaded: Int = 0,
deleted: Int = 0, deleted: Int = 0,
copied: Int = 0, copied: Int = 0,
errors: Int = 0 errors: Int = 0
) )
object Counters {
val uploaded: Lens[Counters, Int] = GenLens[Counters](_.uploaded)
val deleted: Lens[Counters, Int] = GenLens[Counters](_.deleted)
val copied: Lens[Counters, Int] = GenLens[Counters](_.copied)
val errors: Lens[Counters, Int] = GenLens[Counters](_.errors)
}

View file

@ -1,9 +1,7 @@
package net.kemitix.thorp.core package net.kemitix.thorp.core
import monocle.macros.Lenses
import net.kemitix.thorp.domain.LocalFile import net.kemitix.thorp.domain.LocalFile
@Lenses
case class LocalFiles( case class LocalFiles(
localFiles: Stream[LocalFile] = Stream(), localFiles: Stream[LocalFile] = Stream(),
count: Long = 0, count: Long = 0,

View file

@ -1,9 +1,7 @@
package net.kemitix.thorp.core package net.kemitix.thorp.core
import monocle.macros.Lenses
import net.kemitix.thorp.domain.SyncTotals import net.kemitix.thorp.domain.SyncTotals
@Lenses
case class SyncPlan( case class SyncPlan(
actions: Stream[Action] = Stream(), actions: Stream[Action] = Stream(),
syncTotals: SyncTotals = SyncTotals() syncTotals: SyncTotals = SyncTotals()

View file

@ -1,20 +1,11 @@
package net.kemitix.thorp.core package net.kemitix.thorp.core
import cats.effect.IO import cats.effect.IO
import monocle.macros.Lenses
import net.kemitix.thorp.core.Action.{DoNothing, ToCopy, ToDelete, ToUpload} import net.kemitix.thorp.core.Action.{DoNothing, ToCopy, ToDelete, ToUpload}
import net.kemitix.thorp.domain.StorageQueueEvent.DoNothingQueueEvent import net.kemitix.thorp.domain.StorageQueueEvent.DoNothingQueueEvent
import net.kemitix.thorp.domain.{ import net.kemitix.thorp.domain._
Bucket,
LocalFile,
Logger,
StorageQueueEvent,
SyncTotals,
UploadEventListener
}
import net.kemitix.thorp.storage.api.StorageService import net.kemitix.thorp.storage.api.StorageService
@Lenses
case class UnversionedMirrorArchive( case class UnversionedMirrorArchive(
storageService: StorageService, storageService: StorageService,
batchMode: Boolean, batchMode: Boolean,

View file

@ -1,8 +1,5 @@
package net.kemitix.thorp.domain package net.kemitix.thorp.domain
import monocle.macros.Lenses
@Lenses
final case class Bucket( final case class Bucket(
name: String name: String
) )

View file

@ -1,8 +1,8 @@
package net.kemitix.thorp.domain package net.kemitix.thorp.domain
import monocle.macros.Lenses import monocle.Lens
import monocle.macros.GenLens
@Lenses
final case class Config( final case class Config(
bucket: Bucket = Bucket(""), bucket: Bucket = Bucket(""),
prefix: RemoteKey = RemoteKey(""), prefix: RemoteKey = RemoteKey(""),
@ -11,3 +11,12 @@ final case class Config(
batchMode: Boolean = false, batchMode: Boolean = false,
sources: Sources = Sources(List()) sources: Sources = Sources(List())
) )
object Config {
val sources: Lens[Config, Sources] = GenLens[Config](_.sources)
val bucket: Lens[Config, Bucket] = GenLens[Config](_.bucket)
val prefix: Lens[Config, RemoteKey] = GenLens[Config](_.prefix)
val filters: Lens[Config, List[Filter]] = GenLens[Config](_.filters)
val debug: Lens[Config, Boolean] = GenLens[Config](_.debug)
val batchMode: Lens[Config, Boolean] = GenLens[Config](_.batchMode)
}

View file

@ -3,8 +3,6 @@ package net.kemitix.thorp.domain
import java.nio.file.Path import java.nio.file.Path
import java.util.regex.Pattern import java.util.regex.Pattern
import monocle.macros.Lenses
sealed trait Filter sealed trait Filter
object Filter { object Filter {
@ -32,7 +30,6 @@ object Filter {
} }
} }
@Lenses
case class Include( case class Include(
include: String = ".*" include: String = ".*"
) extends Filter { ) extends Filter {
@ -43,7 +40,6 @@ object Filter {
} }
@Lenses
case class Exclude( case class Exclude(
exclude: String exclude: String
) extends Filter { ) extends Filter {

View file

@ -1,8 +1,5 @@
package net.kemitix.thorp.domain package net.kemitix.thorp.domain
import monocle.macros.Lenses
@Lenses
final case class HashModified( final case class HashModified(
hash: MD5Hash, hash: MD5Hash,
modified: LastModified modified: LastModified

View file

@ -1,8 +1,5 @@
package net.kemitix.thorp.domain package net.kemitix.thorp.domain
import monocle.macros.Lenses
@Lenses
final case class KeyModified( final case class KeyModified(
key: RemoteKey, key: RemoteKey,
modified: LastModified modified: LastModified

View file

@ -2,9 +2,6 @@ package net.kemitix.thorp.domain
import java.time.Instant import java.time.Instant
import monocle.macros.Lenses
@Lenses
final case class LastModified( final case class LastModified(
when: Instant = Instant.now when: Instant = Instant.now
) )

View file

@ -3,9 +3,9 @@ package net.kemitix.thorp.domain
import java.io.File import java.io.File
import java.nio.file.Path import java.nio.file.Path
import monocle.macros.Lenses import monocle.Lens
import monocle.macros.GenLens
@Lenses
final case class LocalFile( final case class LocalFile(
file: File, file: File,
source: File, source: File,
@ -41,4 +41,5 @@ object LocalFile {
pathToKey(resolvedPath)) pathToKey(resolvedPath))
} }
val remoteKey: Lens[LocalFile, RemoteKey] = GenLens[LocalFile](_.remoteKey)
} }

View file

@ -4,9 +4,6 @@ import java.util.Base64
import net.kemitix.thorp.domain.QuoteStripper.stripQuotes import net.kemitix.thorp.domain.QuoteStripper.stripQuotes
import monocle.macros.Lenses
@Lenses
final case class MD5Hash( final case class MD5Hash(
in: String in: String
) { ) {

View file

@ -3,9 +3,8 @@ package net.kemitix.thorp.domain
import java.io.File import java.io.File
import java.nio.file.{Path, Paths} import java.nio.file.{Path, Paths}
import monocle.macros.Lenses import monocle.macros.GenLens
@Lenses
final case class RemoteKey( final case class RemoteKey(
key: String key: String
) { ) {
@ -38,3 +37,7 @@ final case class RemoteKey(
RemoteKey(List(key, path).filterNot(_.isEmpty).mkString("/")) RemoteKey(List(key, path).filterNot(_.isEmpty).mkString("/"))
} }
object RemoteKey {
val key = GenLens[RemoteKey](_.key)
}

View file

@ -1,8 +1,5 @@
package net.kemitix.thorp.domain package net.kemitix.thorp.domain
import monocle.macros.Lenses
@Lenses
final case class RemoteMetaData( final case class RemoteMetaData(
remoteKey: RemoteKey, remoteKey: RemoteKey,
hash: MD5Hash, hash: MD5Hash,

View file

@ -1,9 +1,6 @@
package net.kemitix.thorp.domain package net.kemitix.thorp.domain
import monocle.macros.Lenses
// For the LocalFile, the set of matching S3 objects with the same MD5Hash, and any S3 object with the same remote key // For the LocalFile, the set of matching S3 objects with the same MD5Hash, and any S3 object with the same remote key
@Lenses
final case class S3MetaData( final case class S3MetaData(
localFile: LocalFile, localFile: LocalFile,
matchByHash: Set[RemoteMetaData], matchByHash: Set[RemoteMetaData],

View file

@ -1,12 +1,8 @@
package net.kemitix.thorp.domain package net.kemitix.thorp.domain
import monocle.macros.Lenses
/** /**
* A list of objects and their MD5 hash values. * A list of objects and their MD5 hash values.
*/ */
@Lenses
final case class S3ObjectsData( final case class S3ObjectsData(
byHash: Map[MD5Hash, Set[KeyModified]] = Map.empty, byHash: Map[MD5Hash, Set[KeyModified]] = Map.empty,
byKey: Map[RemoteKey, HashModified] = Map.empty byKey: Map[RemoteKey, HashModified] = Map.empty

View file

@ -2,8 +2,6 @@ package net.kemitix.thorp.domain
import java.nio.file.Path import java.nio.file.Path
import monocle.macros.Lenses
/** /**
* The paths to synchronise with target. * The paths to synchronise with target.
* *
@ -14,7 +12,6 @@ import monocle.macros.Lenses
* *
* A path should only occur once in paths. * A path should only occur once in paths.
*/ */
@Lenses
case class Sources( case class Sources(
paths: List[Path] paths: List[Path]
) { ) {

View file

@ -1,7 +1,5 @@
package net.kemitix.thorp.domain package net.kemitix.thorp.domain
import monocle.macros.Lenses
sealed trait StorageQueueEvent { sealed trait StorageQueueEvent {
val order: Int val order: Int
@ -10,21 +8,18 @@ sealed trait StorageQueueEvent {
object StorageQueueEvent { object StorageQueueEvent {
@Lenses
final case class DoNothingQueueEvent( final case class DoNothingQueueEvent(
remoteKey: RemoteKey remoteKey: RemoteKey
) extends StorageQueueEvent { ) extends StorageQueueEvent {
override val order: Int = 0 override val order: Int = 0
} }
@Lenses
final case class CopyQueueEvent( final case class CopyQueueEvent(
remoteKey: RemoteKey remoteKey: RemoteKey
) extends StorageQueueEvent { ) extends StorageQueueEvent {
override val order: Int = 1 override val order: Int = 1
} }
@Lenses
final case class UploadQueueEvent( final case class UploadQueueEvent(
remoteKey: RemoteKey, remoteKey: RemoteKey,
md5Hash: MD5Hash md5Hash: MD5Hash
@ -32,14 +27,12 @@ object StorageQueueEvent {
override val order: Int = 2 override val order: Int = 2
} }
@Lenses
final case class DeleteQueueEvent( final case class DeleteQueueEvent(
remoteKey: RemoteKey remoteKey: RemoteKey
) extends StorageQueueEvent { ) extends StorageQueueEvent {
override val order: Int = 3 override val order: Int = 3
} }
@Lenses
final case class ErrorQueueEvent( final case class ErrorQueueEvent(
remoteKey: RemoteKey, remoteKey: RemoteKey,
e: Throwable e: Throwable
@ -47,7 +40,6 @@ object StorageQueueEvent {
override val order: Int = 10 override val order: Int = 10
} }
@Lenses
final case class ShutdownQueueEvent() extends StorageQueueEvent { final case class ShutdownQueueEvent() extends StorageQueueEvent {
override val order: Int = 99 override val order: Int = 99
} }

View file

@ -1,8 +1,5 @@
package net.kemitix.thorp.domain package net.kemitix.thorp.domain
import monocle.macros.Lenses
@Lenses
case class SyncTotals( case class SyncTotals(
count: Long = 0L, count: Long = 0L,
totalSizeBytes: Long = 0L, totalSizeBytes: Long = 0L,

View file

@ -1,26 +1,21 @@
package net.kemitix.thorp.domain package net.kemitix.thorp.domain
import monocle.macros.Lenses
sealed trait UploadEvent { sealed trait UploadEvent {
def name: String def name: String
} }
object UploadEvent { object UploadEvent {
@Lenses
final case class TransferEvent( final case class TransferEvent(
name: String name: String
) extends UploadEvent ) extends UploadEvent
@Lenses
final case class RequestEvent( final case class RequestEvent(
name: String, name: String,
bytes: Long, bytes: Long,
transferred: Long transferred: Long
) extends UploadEvent ) extends UploadEvent
@Lenses
final case class ByteTransferEvent( final case class ByteTransferEvent(
name: String name: String
) extends UploadEvent ) extends UploadEvent

View file

@ -3,9 +3,6 @@ package net.kemitix.thorp.domain
import net.kemitix.thorp.domain.UploadEvent.RequestEvent import net.kemitix.thorp.domain.UploadEvent.RequestEvent
import net.kemitix.thorp.domain.UploadEventLogger.logRequestCycle import net.kemitix.thorp.domain.UploadEventLogger.logRequestCycle
import monocle.macros.Lenses
@Lenses
case class UploadEventListener( case class UploadEventListener(
localFile: LocalFile, localFile: LocalFile,
index: Int, index: Int,