Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Remove unused non-unit return type compiler warnings (Scala3 preparation) #3211

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions webapi/src/main/scala/dsp/errors/Errors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ import org.knora.webapi.slice.admin.domain.service.KnoraUserService.Errors.UserS
/**
* A trait implemented by all Knora exceptions, which must be serializable and extend [[java.lang.Exception]].
*/
trait KnoraException extends Serializable {
this: Exception =>
{}
}
trait KnoraException extends Serializable

/**
* An abstract base class for exceptions indicating that something about a request made it impossible to fulfil (e.g.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,8 @@ class StringFormatter private (
val ontologyName = ontologyPath.last
val hasBuiltInOntologyName = isBuiltInOntologyName(ontologyName)

if (!hasBuiltInOntologyName) {
ValuesValidator.validateProjectSpecificOntologyName(ontologyName).getOrElse(errorFun)
if (!hasBuiltInOntologyName && ValuesValidator.validateProjectSpecificOntologyName(ontologyName).isEmpty) {
errorFun
}

// If the IRI has the hostname for project-specific ontologies, it can't refer to a built-in or shared ontology.
Expand Down Expand Up @@ -1134,7 +1134,7 @@ class StringFormatter private (
iriInfo.projectCode match {
case Some(projectCode) =>
if (projectCode != DefaultSharedOntologiesProjectCode) {
externalOntologyIri.append(projectCode).append('/')
val _ = externalOntologyIri.append(projectCode).append('/')
}

case None => ()
Expand Down Expand Up @@ -1435,7 +1435,7 @@ class StringFormatter private (
projectCode match {
case Some(code) =>
if (code != DefaultSharedOntologiesProjectCode) {
internalOntologyIri.append('/').append(code)
val _ = internalOntologyIri.append('/').append(code)
}

case None => ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ case class CalendarDateRangeV2(startCalendarDate: CalendarDateV2, endCalendarDat
// Can we represent the start and end dates as a single date?
if (startCalendarDate != endCalendarDate) {
// No. Include the end date.
strBuilder.append(StringFormatter.CalendarSeparator).append(endCalendarDate.toString)
val _ = strBuilder.append(StringFormatter.CalendarSeparator).append(endCalendarDate.toString)
}

strBuilder.toString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,11 @@ case class ConstructQuery(
.append(whereClause.toSparql)

if (orderBy.nonEmpty) {
stringBuilder.append("ORDER BY ").append(orderBy.map(_.toSparql).mkString(" ")).append("\n")
val _ = stringBuilder.append("ORDER BY ").append(orderBy.map(_.toSparql).mkString(" ")).append("\n")
}

if (offset > 0) {
stringBuilder.append("OFFSET ").append(offset)
val _ = stringBuilder.append("OFFSET ").append(offset)
}

stringBuilder.toString
Expand Down Expand Up @@ -618,19 +618,19 @@ case class SelectQuery(
.append(whereClause.toSparql)

if (groupBy.nonEmpty) {
stringBuilder.append("GROUP BY ").append(groupBy.map(_.toSparql).mkString(" ")).append("\n")
val _ = stringBuilder.append("GROUP BY ").append(groupBy.map(_.toSparql).mkString(" ")).append("\n")
}

if (orderBy.nonEmpty) {
stringBuilder.append("ORDER BY ").append(orderBy.map(_.toSparql).mkString(" ")).append("\n")
val _ = stringBuilder.append("ORDER BY ").append(orderBy.map(_.toSparql).mkString(" ")).append("\n")
}

if (offset > 0) {
stringBuilder.append("OFFSET ").append(offset).append("\n")
val _ = stringBuilder.append("OFFSET ").append(offset).append("\n")
}

if (limit.nonEmpty) {
stringBuilder.append(s"LIMIT ${limit.get}").append("\n")
val _ = stringBuilder.append(s"LIMIT ${limit.get}").append("\n")
}

stringBuilder.toString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ final case class PermissionsResponder(

if (req.hasPermissions.isEmpty) throw BadRequestException("Permissions needs to be supplied.")

if (!builtIn.all.map(_.id.value).contains(req.forGroup)) {
GroupIri.from(req.forGroup).getOrElse(throw BadRequestException(s"Invalid group IRI ${req.forGroup}"))
if (!builtIn.all.map(_.id.value).contains(req.forGroup) && GroupIri.from(req.forGroup).isLeft) {
throw BadRequestException(s"Invalid group IRI ${req.forGroup}")
}

verifyHasPermissionsAP(req.hasPermissions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import zio._

import java.time.Instant
import java.util.UUID
import scala.concurrent.Future

import dsp.errors._
import dsp.valueobjects.Iri
Expand Down Expand Up @@ -1088,21 +1087,21 @@ final case class ResourcesResponderV2(
outbound: Boolean,
depth: Int,
traversedEdges: Set[QueryResultEdge] = Set.empty[QueryResultEdge],
): Task[GraphQueryResults] = {
if (depth < 1) Future.failed(AssertionException("Depth must be at least 1"))

val query =
sparql.v2.txt
.getGraphData(
startNodeIri = startNode.nodeIri,
startNodeOnly = false,
maybeExcludeLinkProperty = excludePropertyInternal,
outbound = outbound, // true to query outbound edges, false to query inbound edges
limit = appConfig.v2.graphRoute.maxGraphBreadth,
)
): Task[GraphQueryResults] = ZIO.fail(AssertionException("Depth must be at least 1")).when(depth < 1) *> {
for {
// Get the direct links from/to the start node.
response <- triplestore.query(Select(query))
response <- triplestore.query(
Select(
sparql.v2.txt
.getGraphData(
startNode.nodeIri,
false,
excludePropertyInternal,
outbound,
appConfig.v2.graphRoute.maxGraphBreadth,
),
),
)
rows: Seq[VariableResultsRow] = response.results.bindings

// Did we get any results?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package org.knora.webapi.responders.v2

import org.apache.pekko.http.scaladsl.util.FastFuture
import zio._

import java.time.Instant
Expand Down Expand Up @@ -1868,20 +1867,16 @@ final case class ValuesResponderV2Live(
val submittedInternalPropertyIri: SmartIri = submittedPropertyIri.toOntologySchema(InternalSchema)

if (propertyInfoForSubmittedProperty.isLinkValueProp) {
maybeSubmittedValueType match {
case Some(submittedValueType) =>
if (submittedValueType.toString != OntologyConstants.KnoraApiV2Complex.LinkValue) {
FastFuture.failed(
BadRequestException(
s"A value of type <$submittedValueType> cannot be an object of property <$submittedPropertyIri>",
),
)
}

case None => ()
}

for {
_ <- (maybeSubmittedValueType map { submittedValueType =>
ZIO
.fail(
BadRequestException(
s"A value of type <$submittedValueType> cannot be an object of property <$submittedPropertyIri>",
),
)
.when(submittedValueType.toString != OntologyConstants.KnoraApiV2Complex.LinkValue)
}).getOrElse(ZIO.unit)
internalLinkPropertyIri <- ZIO.attempt(submittedInternalPropertyIri.fromLinkValuePropToLinkProp)

propertyInfoRequestForLinkProperty =
Expand Down
Loading