Skip to content

Commit

Permalink
Delete superfluous implicits.Collections class
Browse files Browse the repository at this point in the history
In the course of upgrading the Frontend codebase to Scala 2.13 we came
across the `implicits.Collections` class, and had trouble updating it
for Scala 2.13: #25190 (comment)

It turns out that we can _delete_ this class with the Scala 2.13
upgrade, rather than have to update it, which is nice!

To reduce the size of the Scala 2.13 upgrade PR, we first removed
every use of `implicits.Collections` that we could while still under
Scala 2.12: #25226

This commit gets rid of `implicits.Collections` altogether. At this
point, all `implicits.Collections` has in it is the code to add a
`distinctBy()` method onto standard Scala collections - this was
introduced November 2012 with #263,
but Scala 2.13 has a new built-in method that works the exact same way!
So we can delete the Frontend implementation.

https://www.scala-lang.org/api/2.13.x/scala/collection/Seq.html#distinctBy%5BB%5D(f:A=%3EB):C
  • Loading branch information
rtyley authored and ioannakok committed Aug 9, 2022
1 parent 8f8aef6 commit 4e50018
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 38 deletions.
3 changes: 1 addition & 2 deletions admin/app/football/model/PA.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package football.model

import pa.{Season, Team}
import implicits.Collections

import java.time.ZoneId

object PA extends Collections {
object PA {

val competitionNames = Map[String, String](
("100", "Premier League"),
Expand Down
1 change: 0 additions & 1 deletion commercial/app/controllers/BookOffersController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class BookOffersController(
) extends BaseController
with ImplicitControllerExecutionContext
with GuLogging
with implicits.Collections
with implicits.Requests {

private def booksSample(isbns: Seq[String], segment: Segment): Seq[Book] =
Expand Down
2 changes: 1 addition & 1 deletion common/app/common/TrailsToRss.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object RssDates {
}
}

object TrailsToRss extends implicits.Collections {
object TrailsToRss {

// The CAPI blocks we would like consumers to request to build our item intro text from
val BlocksToGenerateRssIntro = "body:oldest:10"
Expand Down
28 changes: 0 additions & 28 deletions common/app/implicits/Collections.scala

This file was deleted.

2 changes: 1 addition & 1 deletion common/app/layout/Front.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ case class Front(
containers: Seq[FaciaContainer],
)

object Front extends implicits.Collections {
object Front {
type TrailUrl = String

def itemsVisible(containerDefinition: ContainerDefinition): Int =
Expand Down
1 change: 0 additions & 1 deletion common/app/model/facia/PressedCollection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.gu.facia.api.{models => fapi}
import com.gu.facia.api.utils.ContainerBrandingFinder
import com.gu.facia.client.models.{Branded, TargetedTerritory}
import common.Edition
import implicits.CollectionsOps._
import model.pressed._
import org.joda.time.DateTime
import services.CollectionConfigWithId
Expand Down
3 changes: 1 addition & 2 deletions common/app/services/repositories.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import com.gu.contentapi.client.model.ContentApiError
import com.gu.contentapi.client.model.v1.{ItemResponse, SearchResponse, Section => ApiSection}
import common._
import contentapi.{ContentApiClient, QueryDefaults, SectionTagLookUp, SectionsLookUp}
import implicits.Collections
import model._
import org.joda.time.DateTime
import play.api.mvc.{RequestHeader, Result => PlayResult}

import scala.concurrent.Future

trait Index extends ConciergeRepository with Collections {
trait Index extends ConciergeRepository {

implicit val context: ApplicationContext

Expand Down
2 changes: 1 addition & 1 deletion common/app/views/support/MostPopularTags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import model.Tag
import model.pressed.PressedContent
import implicits.FaciaContentFrontendHelpers.FaciaContentFrontendHelper

object MostPopularTags extends implicits.Collections {
object MostPopularTags {

/** A descending list of the tags that occur most frequently within the given items of content and how frequently
* they occur
Expand Down
2 changes: 1 addition & 1 deletion sport/app/football/feed/agent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ trait Fixtures extends GuLogging {
}
}

trait Results extends GuLogging with implicits.Collections {
trait Results extends GuLogging {

def footballClient: FootballClient
def teamNameBuilder: TeamNameBuilder
Expand Down

0 comments on commit 4e50018

Please sign in to comment.