Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.
13 changes: 7 additions & 6 deletions core/src/main/scala/codesearch/core/search/Search.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ trait Search {
.toList
} yield CSearchPage(results.sortBy(_.pack.name), entity.lists.size, ErrorResponse(""))
}
case scala.util.Failure(exception) =>
{
val message = exception.getMessage
IO(CSearchPage(Seq.empty[Search.PackageResult], 0,
ErrorResponse(message.substring(0,1).toUpperCase + message.substring(1, message.size))))
}
case scala.util.Failure(exception) => {
Comment thread
Kabowyad marked this conversation as resolved.
Outdated
val message = exception.getMessage
IO(
CSearchPage(Seq.empty[Search.PackageResult],
0,
ErrorResponse(message.substring(0, 1).toUpperCase + message.substring(1, message.size))))
Copy link
Copy Markdown
Contributor

@kamilongus kamilongus May 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use .lenght instead .size on strings.
You can make a more elegant code without .substring concatination.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use .lenght instead .size on strings.

Does Scala have a linter that catches those things? (Also it's .length)

Copy link
Copy Markdown
Contributor

@kamilongus kamilongus May 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neongreen
Only IDE inspection support.
image
Or what did you mean?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant a linter that we can run during CI.

I have just tried to run SonarQube on our code, but it didn't find the message.size thing :(

}
}
}

Expand Down