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

Sur Codacy : Prohibit using isDefined on optional types #534

Closed
jdauphant opened this issue Mar 3, 2020 · 2 comments
Closed

Sur Codacy : Prohibit using isDefined on optional types #534

jdauphant opened this issue Mar 3, 2020 · 2 comments
Assignees

Comments

@jdauphant
Copy link
Member

image

La régle "Prohibit using isDefined on optional types" me semble pas pertinente, un avis ? on la supprime ?

@niladic
Copy link
Collaborator

niladic commented Mar 10, 2020

Bah cette règle serait pertinente si Option fold inférait correctement les types en scala, mais c'est pas le cas :(
Typiquement ici ce serait plus clean d'écrire :

    request.session
          .get("userId")
          .orElse(request.queryString.get("token"))
          .orElse(request.queryString.get("key"))
          .fold(
             Ok(views.html.home())
           )(
             _ => TemporaryRedirect(
                s"${routes.ApplicationController.myApplications()}?${request.rawQueryString}"
             ) 

mais l'inférence est tellement mauvaise que le compilateur va t'inférer Ok et te lever une erreur comme quoi TemporaryRedirect n'est pas de type Ok... :(

Du coup, oui, supprime la règle, pas de pertinance due à la lib standard qui est pas top...

@jdauphant
Copy link
Member Author

Ok

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

2 participants