Skip to content

Commit

Permalink
Merge pull request #766 from iRevive/scalafmt-maxColumn
Browse files Browse the repository at this point in the history
scalafmt: set `maxColumn = 120`
  • Loading branch information
iRevive authored Sep 11, 2024
2 parents 0259582 + fd99f52 commit ed30ddb
Show file tree
Hide file tree
Showing 287 changed files with 2,403 additions and 3,764 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Reformat with maxColumn = 120
0afcd5d8cef3c3698c1f10471d4593e22f7c8eb4
1 change: 1 addition & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version = 3.8.3
runner.dialect = scala213
maxColumn = 120

fileOverride {
"glob:**/scala-3/**" {
Expand Down
4 changes: 1 addition & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ ThisBuild / tlSonatypeUseLegacyHost := false
ThisBuild / tlSitePublishBranch := Some("main")

lazy val scalafixSettings = Seq(
semanticdbOptions ++= Seq("-P:semanticdb:synthetics:on").filter(_ =>
!tlIsScala3.value
)
semanticdbOptions ++= Seq("-P:semanticdb:synthetics:on").filter(_ => !tlIsScala3.value)
)

lazy val scalaJSLinkerSettings = Def.settings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ object Attribute {
def apply[A: AttributeKey.KeySelect](name: String, value: A): Attribute[A] =
Attribute(AttributeKey.KeySelect[A].make(name), value)

implicit val showAttribute: Show[Attribute[_]] = (a: Attribute[_]) =>
s"${show"${a.key}"}=${a.value}"
implicit val showAttribute: Show[Attribute[_]] = (a: Attribute[_]) => s"${show"${a.key}"}=${a.value}"

implicit def hashAttribute[T: Hash]: Hash[Attribute[T]] =
Hash.by(a => (a.key, a.value))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import cats.Hash
import cats.Show
import cats.syntax.show._

/** The type of value that can be set with an implementation of this key is
* denoted by the type parameter.
/** The type of value that can be set with an implementation of this key is denoted by the type parameter.
*
* @tparam A
* the type of value that can be set with the key
Expand All @@ -36,16 +35,14 @@ sealed trait AttributeKey[A] {
final def apply(value: A): Attribute[A] = Attribute(this, value)

/** @return
* an [[`AttributeKey`]] of the same type as this key, with name
* transformed by `f`
* an [[`AttributeKey`]] of the same type as this key, with name transformed by `f`
*/
final def transformName(f: String => String): AttributeKey[A] =
new AttributeKey.Impl[A](f(name), `type`)
}

object AttributeKey {
private class Impl[A](val name: String, val `type`: AttributeType[A])
extends AttributeKey[A] {
private class Impl[A](val name: String, val `type`: AttributeType[A]) extends AttributeKey[A] {

override final def toString: String =
Show[AttributeKey[A]].show(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package org.typelevel.otel4s
import cats.Hash
import cats.Show

/** Represents all possible value types for an [[AttributeKey]] and hence the
* types of values that are allowed for [[Attribute]].
/** Represents all possible value types for an [[AttributeKey]] and hence the types of values that are allowed for
* [[Attribute]].
*/
sealed trait AttributeType[A] extends Product with Serializable

Expand Down
67 changes: 26 additions & 41 deletions core/common/src/main/scala/org/typelevel/otel4s/Attributes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,59 +37,51 @@ sealed trait Attributes
with IterableOps[Attribute[_], immutable.Iterable, Attributes] {

/** @return
* an [[`Attribute`]] matching the given attribute name and type, or `None`
* if not found.
* an [[`Attribute`]] matching the given attribute name and type, or `None` if not found.
*/
final def get[T: KeySelect](name: String): Option[Attribute[T]] =
get(KeySelect[T].make(name))

/** @return
* an [[`Attribute`]] matching the given attribute key, or `None` if not
* found
* an [[`Attribute`]] matching the given attribute key, or `None` if not found
*/
def get[T](key: AttributeKey[T]): Option[Attribute[T]]

/** Adds an [[`Attribute`]] with the given name and value to these
* `Attributes`, replacing any `Attribute` with the same name and type if one
* exists.
/** Adds an [[`Attribute`]] with the given name and value to these `Attributes`, replacing any `Attribute` with the
* same name and type if one exists.
*/
final def added[T: KeySelect](name: String, value: T): Attributes =
added(Attribute(name, value))

/** Adds an [[`Attribute`]] with the given key and value to these
* `Attributes`, replacing any `Attribute` with the same key if one exists.
/** Adds an [[`Attribute`]] with the given key and value to these `Attributes`, replacing any `Attribute` with the
* same key if one exists.
*/
final def added[T](key: AttributeKey[T], value: T): Attributes =
added(Attribute(key, value))

/** Adds the given [[`Attribute`]] to these `Attributes`, replacing any
* `Attribute` with the same key if one exists.
/** Adds the given [[`Attribute`]] to these `Attributes`, replacing any `Attribute` with the same key if one exists.
*/
def added(attribute: Attribute[_]): Attributes

/** Adds the given [[`Attribute`]] to these `Attributes`, replacing any
* `Attribute` with the same key if one exists.
/** Adds the given [[`Attribute`]] to these `Attributes`, replacing any `Attribute` with the same key if one exists.
*/
final def +(attribute: Attribute[_]): Attributes =
added(attribute)

/** Invariant overload of
* [[scala.collection.IterableOps.concat `IterableOps#concat`]] that returns
* `Attributes` rather than `Iterable`.
/** Invariant overload of [[scala.collection.IterableOps.concat `IterableOps#concat`]] that returns `Attributes`
* rather than `Iterable`.
*
* If multiple [[`Attribute`]]s in `this` and/or `that` have the same key,
* only the final one (according to `that`'s iterator) will be retained in
* the resulting `Attributes`.
* If multiple [[`Attribute`]]s in `this` and/or `that` have the same key, only the final one (according to `that`'s
* iterator) will be retained in the resulting `Attributes`.
*/
def concat(that: IterableOnce[Attribute[_]]): Attributes =
fromSpecific(this.view ++ that)

/** Invariant overload of [[scala.collection.IterableOps.++ `IterableOps#++`]]
* that returns `Attributes` rather than `Iterable`.
/** Invariant overload of [[scala.collection.IterableOps.++ `IterableOps#++`]] that returns `Attributes` rather than
* `Iterable`.
*
* If multiple [[`Attribute`]]s in `this` and/or `that` have the same key,
* only the final one (according to `that`'s iterator) will be retained in
* the resulting `Attributes`.
* If multiple [[`Attribute`]]s in `this` and/or `that` have the same key, only the final one (according to `that`'s
* iterator) will be retained in the resulting `Attributes`.
*/
final def ++(that: IterableOnce[Attribute[_]]): Attributes =
concat(that)
Expand All @@ -109,8 +101,7 @@ sealed trait Attributes
coll: IterableOnce[Attribute[_]]
): Attributes =
attributesFactory.fromSpecific(coll)
override protected def newSpecificBuilder
: mutable.Builder[Attribute[_], Attributes] =
override protected def newSpecificBuilder: mutable.Builder[Attribute[_], Attributes] =
attributesFactory.newBuilder
override protected[this] def className: String = "Attributes"

Expand All @@ -133,8 +124,7 @@ object Attributes extends SpecificIterableFactory[Attribute[_], Attributes] {
/** Creates [[Attributes]] with the given `attributes`.
*
* @note
* if there are duplicated keys in the given `attributes`, only the last
* occurrence will be retained.
* if there are duplicated keys in the given `attributes`, only the last occurrence will be retained.
*
* @param attributes
* the attributes to use
Expand All @@ -153,8 +143,7 @@ object Attributes extends SpecificIterableFactory[Attribute[_], Attributes] {
/** Creates [[Attributes]] from the given collection.
*
* @note
* if there are duplicated keys in the given `attributes`, only the last
* occurrence will be retained.
* if there are duplicated keys in the given `attributes`, only the last occurrence will be retained.
*
* @param attributes
* the attributes to use
Expand Down Expand Up @@ -191,8 +180,7 @@ object Attributes extends SpecificIterableFactory[Attribute[_], Attributes] {
/** Adds the attribute with the given `key` and `value` to the builder.
*
* @note
* if the given `key` is already present in the builder, the value will
* be overwritten with the given `value`.
* if the given `key` is already present in the builder, the value will be overwritten with the given `value`.
*
* @param key
* the key of the attribute. Denotes the types of the `value`
Expand All @@ -205,12 +193,10 @@ object Attributes extends SpecificIterableFactory[Attribute[_], Attributes] {
this
}

/** Adds the attribute with the given `key` (created from `name`) and
* `value` to the builder.
/** Adds the attribute with the given `key` (created from `name`) and `value` to the builder.
*
* @note
* if the given `key` is already present in the builder, the value will
* be overwritten with the given `value`.
* if the given `key` is already present in the builder, the value will be overwritten with the given `value`.
*
* @param name
* the name of the attribute's key
Expand All @@ -227,8 +213,8 @@ object Attributes extends SpecificIterableFactory[Attribute[_], Attributes] {
/** Adds the given `attribute` to the builder.
*
* @note
* if the key of the given `attribute` is already present in the builder,
* the value will be overwritten with the corresponding given attribute.
* if the key of the given `attribute` is already present in the builder, the value will be overwritten with the
* corresponding given attribute.
*
* @param attribute
* the attribute to add
Expand All @@ -241,9 +227,8 @@ object Attributes extends SpecificIterableFactory[Attribute[_], Attributes] {
/** Adds the given `attributes` to the builder.
*
* @note
* if the keys of the given `attributes` are already present in the
* builder, the values will be overwritten with the corresponding given
* attributes.
* if the keys of the given `attributes` are already present in the builder, the values will be overwritten with
* the corresponding given attributes.
*
* @param attributes
* the attributes to add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,33 @@ import cats.effect.kernel.MonadCancelThrow
import cats.effect.kernel.Resource
import cats.~>

/** A utility for transforming the higher-kinded type `F` to another
* higher-kinded type `G`.
/** A utility for transforming the higher-kinded type `F` to another higher-kinded type `G`.
*/
@annotation.implicitNotFound("No transformer defined from ${F} to ${G}")
trait KindTransformer[F[_], G[_]] {

/** A higher-kinded function that lifts the kind `F` into a `G`.
*
* @note
* This method is usually best implemented by a `liftK` method on `G`'s
* companion object.
* This method is usually best implemented by a `liftK` method on `G`'s companion object.
*/
val liftK: F ~> G

/** Modify the context of `G[A]` using the natural transformation `f`.
*
* This method is "limited" in the sense that while most `mapK` methods can
* modify the context using arbitrary transformations, this method can only
* modify the context using natural transformations.
* This method is "limited" in the sense that while most `mapK` methods can modify the context using arbitrary
* transformations, this method can only modify the context using natural transformations.
*
* @note
* This method is usually best implemented by a `mapK` method on `G`.
*/
def limitedMapK[A](ga: G[A])(f: F ~> F): G[A]

/** Lifts a natural transformation from `F` to `F` into a natural
* transformation from `G` to `G`.
/** Lifts a natural transformation from `F` to `F` into a natural transformation from `G` to `G`.
*
* @note
* Implementors SHOULD NOT override this method; the only reason it is not
* final is for optimization of the identity case.
* Implementors SHOULD NOT override this method; the only reason it is not final is for optimization of the
* identity case.
*/
def liftFunctionK(f: F ~> F): G ~> G =
new (G ~> G) {
Expand Down Expand Up @@ -109,8 +105,7 @@ object KindTransformer {
ga.mapK(f)
}

implicit def resource[F[_]: MonadCancelThrow]
: KindTransformer[F, Resource[F, *]] =
implicit def resource[F[_]: MonadCancelThrow]: KindTransformer[F, Resource[F, *]] =
new KindTransformer[F, Resource[F, *]] {
val liftK: F ~> Resource[F, *] = Resource.liftK
def limitedMapK[A](ga: Resource[F, A])(f: F ~> F): Resource[F, A] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import cats.Hash
import cats.Show
import cats.syntax.show._

/** A baggage can be used to attach log messages or debugging information to the
* context.
/** A baggage can be used to attach log messages or debugging information to the context.
*
* @see
* [[https://opentelemetry.io/docs/specs/otel/baggage/api/]]
Expand All @@ -34,8 +33,7 @@ import cats.syntax.show._
*/
sealed trait Baggage {

/** Returns the entry to which the specified key is mapped, or `None` if this
* map contains no mapping for the key.
/** Returns the entry to which the specified key is mapped, or `None` if this map contains no mapping for the key.
*/
def get(key: String): Option[Baggage.Entry]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,17 @@ trait Contextual[C] { outer =>
/** The type of [[context.Key `Key`]] used by contexts of type `C`. */
type Key[A] <: context.Key[A]

/** Retrieves the value associated with the given key from the context, if
* such a value exists.
/** Retrieves the value associated with the given key from the context, if such a value exists.
*/
def get[A](ctx: C)(key: Key[A]): Option[A]

/** Retrieves the value associated with the given key from the context, if
* such a value exists; otherwise, returns the provided default value.
/** Retrieves the value associated with the given key from the context, if such a value exists; otherwise, returns the
* provided default value.
*/
def getOrElse[A](ctx: C)(key: Key[A], default: => A): A =
get(ctx)(key).getOrElse(default)

/** Creates a copy of this context with the given value associated with the
* given key.
/** Creates a copy of this context with the given value associated with the given key.
*/
def updated[A](ctx: C)(key: Key[A], value: A): C

Expand All @@ -43,20 +41,18 @@ trait Contextual[C] { outer =>

class ContextSyntax(ctx: C) {

/** Retrieves the value associated with the given key from the context, if
* such a value exists.
/** Retrieves the value associated with the given key from the context, if such a value exists.
*/
def get[A](key: Key[A]): Option[A] =
outer.get(ctx)(key)

/** Retrieves the value associated with the given key from the context, if
* such a value exists; otherwise, returns the provided default value.
/** Retrieves the value associated with the given key from the context, if such a value exists; otherwise, returns
* the provided default value.
*/
def getOrElse[A](key: Key[A], default: => A): A =
outer.getOrElse(ctx)(key, default)

/** Creates a copy of this context with the given value associated with the
* given key.
/** Creates a copy of this context with the given value associated with the given key.
*/
def updated[A](key: Key[A], value: A): C =
outer.updated(ctx)(key, value)
Expand All @@ -65,8 +61,7 @@ trait Contextual[C] { outer =>

object Contextual {

/** A type alias for a [[`Contextual`]] explicitly parameterized by its
* [[Contextual.Key `Key`]] type.
/** A type alias for a [[`Contextual`]] explicitly parameterized by its [[Contextual.Key `Key`]] type.
*/
type Keyed[C, K[X] <: Key[X]] = Contextual[C] { type Key[A] = K[A] }

Expand Down
Loading

0 comments on commit ed30ddb

Please sign in to comment.