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

Experimental ​function-type-reference-spacing rule Unexpected whitespace for anonymous functions #1440

Closed
ViktorPetrovski opened this issue Mar 31, 2022 · 1 comment · Fixed by #1443

Comments

@ViktorPetrovski
Copy link

ViktorPetrovski commented Mar 31, 2022

Expected Behavior

The rule experimental:function-type-reference-spacing is complaining with Unexpected whitespace for anonymous functions:
val annonymousFunction = fun(inString: String): String? = "Test string"

Observed Behavior

I believe that the anonymous function is properly written and should not complain about unexpected whitespace after the = operator. And removing the whitespace after the operator complains about Missing spacing after "="

Steps to Reproduce

Running Ktlin check that checks for experimental rules should reproduce this

Your Environment

  • Version of ktlint used: 0.45.1
  • Relevant parts of the .editorconfig settings n/a
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): n/a
  • Version of Gradle used (if applicable): n/a
  • Operating System and version: n/a
paul-dingemans added a commit to paul-dingemans/ktlint that referenced this issue Apr 2, 2022
…tion

Rule should not depend on the existence of the function identifier
as it is also possible to define anonymous functions. Checking of
anonymous and named function should be identical.

Closes pinterest#1440
@paul-dingemans
Copy link
Collaborator

paul-dingemans commented Apr 2, 2022

Tnx for reporting. Your example is correct. I was not aware that anonymous functions could be declared this way.

paul-dingemans added a commit to paul-dingemans/ktlint that referenced this issue Apr 2, 2022
@paul-dingemans paul-dingemans added this to the 0.46.0 milestone Apr 2, 2022
paul-dingemans added a commit that referenced this issue Apr 27, 2022
…tion (#1443)

* Fix false positive FunctionTypeReferenceSpacingRule in anonymous function

Rule should not depend on the existence of the function identifier
as it is also possible to define anonymous functions. Checking of
anonymous and named function should be identical.

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

Successfully merging a pull request may close this issue.

2 participants