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]].
* [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
** Changed

View file

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

View file

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

View file

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

View file

@ -1,9 +1,9 @@
package net.kemitix.thorp.core
import cats.Semigroup
import monocle.macros.Lenses
import monocle.Lens
import monocle.macros.GenLens
@Lenses
case class ConfigOptions(
options: List[ConfigOption] = List()
) extends Semigroup[ConfigOptions] {
@ -24,3 +24,8 @@ case class ConfigOptions(
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
import monocle.macros.Lenses
import monocle.Lens
import monocle.macros.GenLens
@Lenses
final case class Counters(
uploaded: Int = 0,
deleted: Int = 0,
copied: 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
import monocle.macros.Lenses
import net.kemitix.thorp.domain.LocalFile
@Lenses
case class LocalFiles(
localFiles: Stream[LocalFile] = Stream(),
count: Long = 0,

View file

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

View file

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

View file

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

View file

@ -1,8 +1,8 @@
package net.kemitix.thorp.domain
import monocle.macros.Lenses
import monocle.Lens
import monocle.macros.GenLens
@Lenses
final case class Config(
bucket: Bucket = Bucket(""),
prefix: RemoteKey = RemoteKey(""),
@ -11,3 +11,12 @@ final case class Config(
batchMode: Boolean = false,
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.util.regex.Pattern
import monocle.macros.Lenses
sealed trait Filter
object Filter {
@ -32,7 +30,6 @@ object Filter {
}
}
@Lenses
case class Include(
include: String = ".*"
) extends Filter {
@ -43,7 +40,6 @@ object Filter {
}
@Lenses
case class Exclude(
exclude: String
) extends Filter {

View file

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

View file

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

View file

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

View file

@ -3,9 +3,9 @@ package net.kemitix.thorp.domain
import java.io.File
import java.nio.file.Path
import monocle.macros.Lenses
import monocle.Lens
import monocle.macros.GenLens
@Lenses
final case class LocalFile(
file: File,
source: File,
@ -41,4 +41,5 @@ object LocalFile {
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 monocle.macros.Lenses
@Lenses
final case class MD5Hash(
in: String
) {

View file

@ -3,9 +3,8 @@ package net.kemitix.thorp.domain
import java.io.File
import java.nio.file.{Path, Paths}
import monocle.macros.Lenses
import monocle.macros.GenLens
@Lenses
final case class RemoteKey(
key: String
) {
@ -38,3 +37,7 @@ final case class RemoteKey(
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
import monocle.macros.Lenses
@Lenses
final case class RemoteMetaData(
remoteKey: RemoteKey,
hash: MD5Hash,

View file

@ -1,9 +1,6 @@
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
@Lenses
final case class S3MetaData(
localFile: LocalFile,
matchByHash: Set[RemoteMetaData],

View file

@ -1,12 +1,8 @@
package net.kemitix.thorp.domain
import monocle.macros.Lenses
/**
* A list of objects and their MD5 hash values.
*/
@Lenses
final case class S3ObjectsData(
byHash: Map[MD5Hash, Set[KeyModified]] = 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 monocle.macros.Lenses
/**
* The paths to synchronise with target.
*
@ -14,7 +12,6 @@ import monocle.macros.Lenses
*
* A path should only occur once in paths.
*/
@Lenses
case class Sources(
paths: List[Path]
) {

View file

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

View file

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

View file

@ -1,26 +1,21 @@
package net.kemitix.thorp.domain
import monocle.macros.Lenses
sealed trait UploadEvent {
def name: String
}
object UploadEvent {
@Lenses
final case class TransferEvent(
name: String
) extends UploadEvent
@Lenses
final case class RequestEvent(
name: String,
bytes: Long,
transferred: Long
) extends UploadEvent
@Lenses
final case class ByteTransferEvent(
name: String
) 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.UploadEventLogger.logRequestCycle
import monocle.macros.Lenses
@Lenses
case class UploadEventListener(
localFile: LocalFile,
index: Int,