Skip to content

Commit

Permalink
Updated scalafmt and configured docstring wrapping (#2752)
Browse files Browse the repository at this point in the history
* Configured scalafmt docstring formatting

* Fixed docstring for JsonSyntax

* More formatting fixes
  • Loading branch information
bogdanromanx authored Sep 2, 2021
1 parent d4bbadd commit e6234ca
Show file tree
Hide file tree
Showing 517 changed files with 8,844 additions and 4,892 deletions.
6 changes: 4 additions & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
style = defaultWithAlign
maxColumn = 120
align.preset = most
rewrite.rules = [SortImports, SortModifiers]
rewrite.rules = [Imports, SortModifiers]
rewrite.imports.sort = original
importSelectors = singleLine
docstrings.blankFirstLine = yes
version = 2.7.5
docstrings.wrap = yes
version = 3.0.1
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import scala.io.Source
/*
scalafmt: {
maxColumn = 150
align.tokens.add = [
align.tokens."+" = [
{ code = ":=", owner = "Term.ApplyInfix" }
{ code = "+=", owner = "Term.ApplyInfix" }
{ code = "++=", owner = "Term.ApplyInfix" }
Expand Down
15 changes: 10 additions & 5 deletions cli/src/main/scala/ch/epfl/bluebrain/nexus/cli/Cli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import distage.{LocatorRef, TagK}
/**
* Entrypoint to the application.
*
* @param locatorOpt an optional locator instance to be cascaded to all commands
* @param locatorOpt
* an optional locator instance to be cascaded to all commands
*/
class Cli[F[_]: TagK: Parallel: ContextShift: Timer](locatorOpt: Option[LocatorRef])(implicit F: ConcurrentEffect[F]) {

Expand All @@ -31,8 +32,10 @@ class Cli[F[_]: TagK: Parallel: ContextShift: Timer](locatorOpt: Option[LocatorR
/**
* Execute the application by evaluating the intent and config from the command line arguments.
*
* @param args the command line arguments to evaluate
* @param env the application environment
* @param args
* the command line arguments to evaluate
* @param env
* the application environment
*/
def command(args: List[String], env: Map[String, String] = Map.empty): F[ExitCode] =
Command("nexus-cli", "Nexus CLI") {
Expand All @@ -49,8 +52,10 @@ object Cli {
/**
* Execute the application by evaluating the intent and config from the command line arguments.
*
* @param args the command line arguments to evaluate
* @param env the application environment
* @param args
* the command line arguments to evaluate
* @param env
* the application environment
*/
// $COVERAGE-OFF$
def apply[F[_]: Parallel: ContextShift: ConcurrentEffect: Timer: TagK](
Expand Down
36 changes: 24 additions & 12 deletions cli/src/main/scala/ch/epfl/bluebrain/nexus/cli/CliError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ object CliError {
/**
* Attempt to construct a [[ClientError]] from the passed HTTP status code and message
*
* @return Some(clientError) if the code is not Successful, false otherwise
* @return
* Some(clientError) if the code is not Successful, false otherwise
*/
def apply(code: Status, message: String): Option[ClientError] =
Try(unsafe(code, message)).toOption

/**
* Construct a [[ClientError]] from the passed HTTP status code and message
*
* @throws IllegalArgumentException if the code is a Successful HTTP Status code is 2xx
* @throws IllegalArgumentException
* if the code is a Successful HTTP Status code is 2xx
*/
def unsafe(code: Status, message: String): ClientError =
code.responseClass match {
Expand All @@ -63,9 +65,12 @@ object CliError {
/**
* A serialization error when attempting to cast response.
*
* @param message the error message
* @param tpe the type into which the serialization was attempted
* @param original the optionally available original payload
* @param message
* the error message
* @param tpe
* the type into which the serialization was attempted
* @param original
* the optionally available original payload
*/
final case class SerializationError(message: String, tpe: String, original: Option[String] = None)
extends ClientError {
Expand All @@ -77,8 +82,10 @@ object CliError {
/**
* A Client status error (HTTP status codes 4xx).
*
* @param code the HTTP status code
* @param message the error message
* @param code
* the HTTP status code
* @param message
* the error message
*/
final case class ClientStatusError(code: Status, message: String) extends ClientError {
val reason: String = s"an HTTP response that should have been successful, returned the HTTP status code '$code'"
Expand All @@ -88,8 +95,10 @@ object CliError {
/**
* A server status error (HTTP status codes 5xx).
*
* @param code the HTTP status code
* @param message the error message
* @param code
* the HTTP status code
* @param message
* the error message
*/
final case class ServerStatusError(code: Status, message: String) extends ClientError {
val reason: String = s"an HTTP response that should have been successful, returned the HTTP status code '$code'"
Expand All @@ -99,8 +108,10 @@ object CliError {
/**
* Some other response error which is not 4xx nor 5xx
*
* @param code the HTTP status code
* @param message the error message
* @param code
* the HTTP status code
* @param message
* the error message
*/
final case class UnexpectedStatusError(code: Status, message: String) extends ClientError {
val reason: String = s"an HTTP response that should have been successful, returned the HTTP status code '$code'"
Expand All @@ -110,7 +121,8 @@ object CliError {
/**
* An unexpected error thrown by the client
*
* @param message the error message
* @param message
* the error message
*/
final case class Unexpected(message: String) extends ClientError {
val reason: String = s"an HTTP response that should have been successful, failed unexpectedly"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,24 @@ import pureconfig.error.CannotConvert
sealed trait ClientRetryCondition {

/**
* Decides whether it is worth to retry or not depending on the passed [[ClientError]].
* The actual retry will depend on the [[ch.epfl.bluebrain.nexus.cli.config.RetryStrategyConfig]].
* Decides whether it is worth to retry or not depending on the passed [[ClientError]]. The actual retry will depend
* on the [[ch.epfl.bluebrain.nexus.cli.config.RetryStrategyConfig]].
*
* @param error the client error
* @return true = retry; false = do not retry
* @param error
* the client error
* @return
* true = retry; false = do not retry
*/
def apply(error: ClientError): Boolean

/**
* Decides whether it is worth to retry or not depending on the passed either of [[ClientError]].
* The actual retry will depend on the [[ch.epfl.bluebrain.nexus.cli.config.RetryStrategyConfig]].
* Decides whether it is worth to retry or not depending on the passed either of [[ClientError]]. The actual retry
* will depend on the [[ch.epfl.bluebrain.nexus.cli.config.RetryStrategyConfig]].
*
* @param either an [[Either]] where the Left is a [[ClientError]]
* @return true = retry; false = do not retry
* @param either
* an [[Either]] where the Left is a [[ClientError]]
* @return
* true = retry; false = do not retry
*/
def fromEither[A](either: ClientErrOr[A]): Boolean =
either match {
Expand All @@ -31,20 +35,24 @@ sealed trait ClientRetryCondition {
}

/**
* Decide whether it is worth to avoid retrying or not depending on the passed [[ClientError]].
* The actual retry will depend on the [[ch.epfl.bluebrain.nexus.cli.config.RetryStrategyConfig]].
* Decide whether it is worth to avoid retrying or not depending on the passed [[ClientError]]. The actual retry will
* depend on the [[ch.epfl.bluebrain.nexus.cli.config.RetryStrategyConfig]].
*
* @param error the client error
* @return true = do not retry; false = retry
* @param error
* the client error
* @return
* true = do not retry; false = retry
*/
def notRetry(error: ClientError): Boolean = !apply(error)

/**
* Decide whether it is worth to avoid retrying or not depending on the passed either of [[ClientError]].
* The actual retry will depend on the [[ch.epfl.bluebrain.nexus.cli.config.RetryStrategyConfig]].
* Decide whether it is worth to avoid retrying or not depending on the passed either of [[ClientError]]. The actual
* retry will depend on the [[ch.epfl.bluebrain.nexus.cli.config.RetryStrategyConfig]].
*
* @param either an [[Either]] where the Left is a [[ClientError]]
* @return true = do not retry; false = retry
* @param either
* an [[Either]] where the Left is a [[ClientError]]
* @return
* true = do not retry; false = retry
*/
def notRetryFromEither[A](either: ClientErrOr[A]): Boolean = !fromEither(either)

Expand All @@ -61,8 +69,8 @@ object ClientRetryCondition {
}

/**
* Retry when the Client response returns a HTTP Server Error (status codes 5xx) that is not a [[Status.GatewayTimeout]].
* Alternatively, retries when the Client returns an Unexpected error
* Retry when the Client response returns a HTTP Server Error (status codes 5xx) that is not a
* [[Status.GatewayTimeout]]. Alternatively, retries when the Client returns an Unexpected error
*/
final case object OnServerError extends ClientRetryCondition {
override def apply(error: ClientError): Boolean =
Expand Down
8 changes: 4 additions & 4 deletions cli/src/main/scala/ch/epfl/bluebrain/nexus/cli/Console.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import scala.{Console => ScalaConsole}
trait Console[F[_]] {

/**
* Prints the passed ''line'' through the console to the standard output and then terminates the line.
* The evaluation is delayed to the ''F'' effect type.
* Prints the passed ''line'' through the console to the standard output and then terminates the line. The evaluation
* is delayed to the ''F'' effect type.
*/
def println(line: String): F[Unit]

/**
* Prints the passed ''line'' through the console to the standard error and then terminates the line.
* The evaluation is delayed to the ''F'' effect type.
* Prints the passed ''line'' through the console to the standard error and then terminates the line. The evaluation
* is delayed to the ''F'' effect type.
*/
def printlnErr(line: String): F[Unit]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import fs2.Pipe
object ProjectionPipes {

/**
* Print the progress of the consumed events through the passed ''console''.
* It prints every 100 consumed events, distinguishing skip, errors and success events.
* Print the progress of the consumed events through the passed ''console''. It prints every 100 consumed events,
* distinguishing skip, errors and success events.
*
* @return it returns the successful events, ignoring the failures and the skipped
* @return
* it returns the successful events, ignoring the failures and the skipped
*/
def printEventProgress[F[_], A, E <: CliError](
console: Console[F]
Expand All @@ -34,10 +35,11 @@ object ProjectionPipes {
}.collect { case Right(Some(v)) => v }

/**
* Print the progress of the evaluated projection through the passed ''console''.
* It prints every 100 consumed events, distinguishing errors and success.
* Print the progress of the evaluated projection through the passed ''console''. It prints every 100 consumed
* events, distinguishing errors and success.
*
* @return it returns the successfully evaluated projections, ignoring the failures
* @return
* it returns the successfully evaluated projections, ignoring the failures
*/
def printProjectionProgress[F[_], A, E <: CliError](
console: Console[F]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,28 @@ trait EventStreamClient[F[_]] {
/**
* Fetch the event stream for all Nexus resources.
*
* @param lastEventId the optional starting event offset
* @param lastEventId
* the optional starting event offset
*/
def apply(lastEventId: Option[Offset]): F[EventStream[F]]

/**
* Fetch the event stream for all Nexus resources in the passed ''organization''.
*
* @param organization the organization label
* @param lastEventId the optional starting event offset
* @param organization
* the organization label
* @param lastEventId
* the optional starting event offset
*/
def apply(organization: OrgLabel, lastEventId: Option[Offset]): F[EventStream[F]]

/**
* Fetch the event stream for all Nexus resources in the passed ''organization'' and ''project''.
*
* @param organization the organization label
* @param lastEventId the optional starting event offset
* @param organization
* the organization label
* @param lastEventId
* the optional starting event offset
*/
def apply(organization: OrgLabel, project: ProjectLabel, lastEventId: Option[Offset]): F[EventStream[F]]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ trait InfluxClient[F[_]] {
/**
* Write an InfluxDB point to a database.
*
* @param point the influxDB line protocol point to write
* @param point
* the influxDB line protocol point to write
*/
def write(point: InfluxPoint): F[ClientErrOr[Unit]]

/**
* Query data with influxQL
* @param ql the query in influxQL query language
* @param ql
* the query in influxQL query language
*/
def query(ql: String): F[ClientErrOr[Json]]

Expand Down Expand Up @@ -74,9 +76,12 @@ object InfluxClient {
/**
* Construct an instance of [[InfluxClient]].
*
* @param client the underlying HTTP client
* @param config the application config
* @param console [[Console]] for logging
* @param client
* the underlying HTTP client
* @param config
* the application config
* @param console
* [[Console]] for logging
*/
final def apply[F[_]: Sync: Timer](
client: Client[F],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ import org.http4s.{EntityEncoder, MediaType}
import scala.util.Try

/**
* Class representing InfluxDb line protocol point.
* See [[https://docs.influxdata.com/influxdb/v1.7/write_protocols/line_protocol_reference/ InfluxDb reference]] for more details.
* Class representing InfluxDb line protocol point. See
* [[https://docs.influxdata.com/influxdb/v1.7/write_protocols/line_protocol_reference/ InfluxDb reference]] for more
* details.
*
* @param measurement the influxDB line protocol measurement name
* @param tags the influxDB line protocol tags
* @param values the influxDB line protocol values
* @param timestamp the optional influxDB line protocol timestamp
* @param measurement
* the influxDB line protocol measurement name
* @param tags
* the influxDB line protocol tags
* @param values
* the influxDB line protocol values
* @param timestamp
* the optional influxDB line protocol timestamp
*/
final case class InfluxPoint(
measurement: String,
Expand All @@ -40,7 +45,8 @@ object InfluxPoint {
/**
* Create a series of [[InfluxPoint]] from [[SparqlResults]].
*
* @param results SPARQL query results
* @param results
* SPARQL query results
*/
def fromSparqlResults(
results: SparqlResults,
Expand Down
Loading

0 comments on commit e6234ca

Please sign in to comment.