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

Scapegoat result #130

Open
mccartney opened this issue Mar 31, 2020 · 0 comments
Open

Scapegoat result #130

mccartney opened this issue Mar 31, 2020 · 0 comments

Comments

@mccartney
Copy link
Collaborator

mccartney commented Mar 31, 2020

https://github.com/sksamuel/scapegoat static analysis tool reports several warnings in our code base:

Scapegoat Inspections
Errors 7 Warnings 8 Infos 4

slack.SlackUtil.scala:10
Error Use of unsafe Traversable methods.
com.sksamuel.scapegoat.inspections.collections.UnsafeTraversableMethods
The following methods on Traversable are considered to be unsafe (head,
tail, init, last, reduce, reduceLeft, reduceRight, max, maxBy, min,
minBy).
x$1.subgroups.head

slack.api.BlockingSlackApiClient.scala:126
Info Max parameters com.sksamuel.scapegoat.inspections.MaxParameters
Methods having a large number of parameters are more difficult to
reason about, consider refactoring this code.

slack.api.SlackApiClient.scala:987
Error Incorrectly named exceptions
com.sksamuel.scapegoat.inspections.exception.IncorrectlyNamedExceptions
Class named exception does not derive from Exception / class derived
from Exception is not named *Exception.
case class InvalidResponseError extends scala.package.Exception with
Product with Serializable {
private[this] val status: Int = _;
def status: Int = InvalidResponseError.this.status;
private[this] val body: String = _;
def body: String =
InvalidResponseError.this.body; def (status: Int, body: String):
slack.api.Inva

slack.api.SlackApiClient.scala:988
Error Incorrectly named exceptions
com.sksamuel.scapegoat.inspections.exception.IncorrectlyNamedExceptions
Class named exception does not derive from Exception / class derived
from Exception is not named *Exception.
case class ApiError extends scala.package.Exception with Product with
Serializable { private[this] val code:
String = _; def
code: String = ApiError.this.code; def (code: String):
slack.api.ApiError = { ApiError.super.(code); () };
def copy(code: String = code): slack.api.ApiError = new ApiError(code);
def copy$default$1: String = ApiError.this.code; overr

slack.api.SlackApiClient.scala:368
Info Max parameters com.sksamuel.scapegoat.inspections.MaxParameters
Methods having a large number of parameters are more difficult to
reason about, consider refactoring this code.

slack.api.SlackApiClient.scala:27
Error Use of Try.get com.sksamuel.scapegoat.inspections.unsafe.TryGet
Using Try.get is unsafe because it will throw the underlying exception
in case of a Failure. Use the following instead: Try.getOrElse,
Try.fold, pattern matching or don't take the value out of the container
and map over it to transform it.
scala.util.Try.apply[String](SlackApiClient.this.config.getString("slac
k-scala-client.http.useproxy")).map[Boolean](((x$1: String) =>
scala.Predef.augmentString(x$1).toBoolean)).recover[Boolean](({
@serialversionuid(value = 0) final class $anonfun extends
scala.runtime.AbstractPartialFunction[Throwable,Boolean] with
Serializable { def (): <$anon: Throwable => Boolean> = {
$anonfun.super.(); () }; final override def applyOrElse[A1 <:
Throwable, B1

slack.api.SlackApiClient.scala:100
Warning Variable shadowing
com.sksamuel.scapegoat.inspections.VariableShadowing
Variable shadowing is very useful, but can easily lead to nasty bugs in
your code. Shadowed variables can be potentially confusing to other
maintainers when the same name is adopted to have a new meaning in a
nested scope.
val entity: akka.http.scaladsl.model.HttpEntity.Strict = _

slack.models.package.scala:310
Error Use of Option.get
com.sksamuel.scapegoat.inspections.option.OptionGet
Using Option.get defeats the purpose of using Option in the first
place. Use the following instead: Option.getOrElse, Option.fold,
pattern matching or don't take the value out of the container and map
over it to transform it.
etype.get

slack.models.package.scala:9
Warning Unused parameter
com.sksamuel.scapegoat.inspections.unneccesary.UnusedMethodParameter
Unused constructor or method parameters should be removed.
Unused method parameter (val rightKey: String = _).

slack.rtm.RtmState.scala:63
Warning Variable shadowing
com.sksamuel.scapegoat.inspections.VariableShadowing
Variable shadowing is very useful, but can easily lead to nasty bugs in
your code. Shadowed variables can be potentially confusing to other
maintainers when the same name is adopted to have a new meaning in a
nested scope.
val start: slack.api.RtmStartState = _

slack.rtm.SimpleEventHandlers.scala:15
Warning Catch exception
com.sksamuel.scapegoat.inspections.exception.CatchException
Did you intend to catch all exceptions? Consider catching a more
specific exception class.
try { EventHandlerActor.this.f.apply(e) } catch { case (e @ (_:
Exception)) => EventHandlerActor.this.log.error(e, "Caught exception in
event handler") }

slack.rtm.SimpleEventHandlers.scala:34
Warning Catch exception
com.sksamuel.scapegoat.inspections.exception.CatchException
Did you intend to catch all exceptions? Consider catching a more
specific exception class.
try { MessageHandlerActor.this.f.apply(m) } catch { case (e @ (_:
Exception)) => MessageHandlerActor.this.log.error(e, "Caught exception
in message handler") }

slack.rtm.SlackRtmClient.scala:125
Warning Catch exception
com.sksamuel.scapegoat.inspections.exception.CatchException
Did you intend to catch all exceptions? Consider catching a more
specific exception class.
try { val payload: String = message.getStrictText; val payloadJson:
play.api.libs.json.JsValue = play.api.libs.json.Json.parse(payload); if
(json.this.JsValue.jsValueToJsLookup(payloadJson).("type").asOptStrin
g
.isDefined.||(json.this.JsValue.jsValueT
oJsLookup(pa

slack.rtm.SlackRtmClient.scala:186
Warning Catch exception
com.sksamuel.scapegoat.inspections.exception.CatchException
Did you intend to catch all exceptions? Consider catching a more
specific exception class.
try { val initialRtmState: slack.api.RtmStartState =
SlackRtmConnectionActor.this.apiClient.startRealTimeMessageSession()(Sl
ackRtmConnectionActor.this.system);
SlackRtmConnectionActor.this.state.reset(initialRtmState);
SlackRtmConnectionActor.this.webSocketClient_=(scala.Some.apply[akka.ac
tor.

slack.rtm.SlackRtmClient.scala:94
Info Empty case class
com.sksamuel.scapegoat.inspections.EmptyCaseClass
An empty case class can be rewritten as a case object.

slack.rtm.SlackRtmClient.scala:97
Info Empty case class
com.sksamuel.scapegoat.inspections.EmptyCaseClass
An empty case class can be rewritten as a case object.

slack.rtm.SlackRtmClient.scala:199
Error Use of Option.get
com.sksamuel.scapegoat.inspections.option.OptionGet
Using Option.get defeats the purpose of using Option in the first
place. Use the following instead: Option.getOrElse, Option.fold,
pattern matching or don't take the value out of the container and map
over it to transform it.
SlackRtmConnectionActor.this.webSocketClient.get

slack.rtm.SlackRtmClient.scala:201
Warning Variable shadowing
com.sksamuel.scapegoat.inspections.VariableShadowing
Variable shadowing is very useful, but can easily lead to nasty bugs in
your code. Shadowed variables can be potentially confusing to other
maintainers when the same name is adopted to have a new meaning in a
nested scope.
val actor: akka.actor.ActorRef = _

slack.rtm.WebSocketClientActor.scala:34
Error Use of Try.get com.sksamuel.scapegoat.inspections.unsafe.TryGet
Using Try.get is unsafe because it will throw the underlying exception
in case of a Failure. Use the following instead: Try.getOrElse,
Try.fold, pattern matching or don't take the value out of the container
and map over it to transform it.
scala.util.Try.applyString.map[Boolean](((x$1: String) =>
scala.Predef.augmentString(x$1).toBoolean)).recover[Boolean](({
@serialversionuid(value = 0) final class $anonfun extends
scala.runtime.AbstractPartialFunction[Throwable,Boolean] with
Serializable { def (): <$anon: Throwable => Boolean> = {
$anonfun.super.(); () }; final override def applyOrElse[A1 <:
Throwab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant