Skip to content
This repository has been archived by the owner on Dec 3, 2022. It is now read-only.

Commit

Permalink
NullPointerException creating scaladoc (#115)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
kemitix authored Jul 19, 2019
1 parent c33fa05 commit 32ef58f
Show file tree
Hide file tree
Showing 26 changed files with 48 additions and 90 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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 := {}
)

Expand Down
5 changes: 0 additions & 5 deletions core/src/main/scala/net/kemitix/thorp/core/Action.scala
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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,
Expand All @@ -32,7 +28,6 @@ object Action {
size: Long
) extends Action

@Lenses
final case class ToDelete(
bucket: Bucket,
remoteKey: RemoteKey,
Expand Down
7 changes: 0 additions & 7 deletions core/src/main/scala/net/kemitix/thorp/core/ConfigOption.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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] {
Expand All @@ -24,3 +24,8 @@ case class ConfigOptions(
options contains elem

}

object ConfigOptions {
val options: Lens[ConfigOptions, List[ConfigOption]] =
GenLens[ConfigOptions](_.options)
}
11 changes: 9 additions & 2 deletions core/src/main/scala/net/kemitix/thorp/core/Counters.scala
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 0 additions & 2 deletions core/src/main/scala/net/kemitix/thorp/core/LocalFiles.scala
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/scala/net/kemitix/thorp/core/SyncPlan.scala
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 0 additions & 3 deletions domain/src/main/scala/net/kemitix/thorp/domain/Bucket.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package net.kemitix.thorp.domain

import monocle.macros.Lenses

@Lenses
final case class Bucket(
name: String
)
13 changes: 11 additions & 2 deletions domain/src/main/scala/net/kemitix/thorp/domain/Config.scala
Original file line number Diff line number Diff line change
@@ -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(""),
Expand All @@ -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)
}
4 changes: 0 additions & 4 deletions domain/src/main/scala/net/kemitix/thorp/domain/Filter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -32,7 +30,6 @@ object Filter {
}
}

@Lenses
case class Include(
include: String = ".*"
) extends Filter {
Expand All @@ -43,7 +40,6 @@ object Filter {

}

@Lenses
case class Exclude(
exclude: String
) extends Filter {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package net.kemitix.thorp.domain

import monocle.macros.Lenses

@Lenses
final case class HashModified(
hash: MD5Hash,
modified: LastModified
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package net.kemitix.thorp.domain

import monocle.macros.Lenses

@Lenses
final case class KeyModified(
key: RemoteKey,
modified: LastModified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -41,4 +41,5 @@ object LocalFile {
pathToKey(resolvedPath))
}

val remoteKey: Lens[LocalFile, RemoteKey] = GenLens[LocalFile](_.remoteKey)
}
3 changes: 0 additions & 3 deletions domain/src/main/scala/net/kemitix/thorp/domain/MD5Hash.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down Expand Up @@ -38,3 +37,7 @@ final case class RemoteKey(
RemoteKey(List(key, path).filterNot(_.isEmpty).mkString("/"))

}

object RemoteKey {
val key = GenLens[RemoteKey](_.key)
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package net.kemitix.thorp.domain

import monocle.macros.Lenses

@Lenses
final case class RemoteMetaData(
remoteKey: RemoteKey,
hash: MD5Hash,
Expand Down
Original file line number Diff line number Diff line change
@@ -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],
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 0 additions & 3 deletions domain/src/main/scala/net/kemitix/thorp/domain/Sources.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package net.kemitix.thorp.domain

import java.nio.file.Path

import monocle.macros.Lenses

/**
* The paths to synchronise with target.
*
Expand All @@ -14,7 +12,6 @@ import monocle.macros.Lenses
*
* A path should only occur once in paths.
*/
@Lenses
case class Sources(
paths: List[Path]
) {
Expand Down
Loading

0 comments on commit 32ef58f

Please sign in to comment.