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

Introduce TypeMemberOrder bug checker #636

Open
wants to merge 48 commits into
base: master
Choose a base branch
from

Conversation

benhalasi
Copy link
Contributor

@benhalasi benhalasi commented May 18, 2023

#595

Suggested commit message

Introduce `TypeMemberOrder` check (#636)

@github-actions

This comment was marked as outdated.

@benhalasi benhalasi force-pushed the benhalasi/sort-members-constructors-methods branch from 00eebf3 to ebb9041 Compare May 18, 2023 08:48
@github-actions
Copy link

  • Surviving mutants in this change: 23
  • Killed mutants in this change: 63
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.MemberOrdering 23 63

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@benhalasi benhalasi linked an issue May 18, 2023 that may be closed by this pull request
3 tasks
@benhalasi
Copy link
Contributor Author

benhalasi commented May 18, 2023

Verifying that the whitespace is untouched maybe a bit harder than I thought because TestMode.TEXT_MATCH formats both input and output.

I looked into doTest and TestMode and it doesn't seem too hard to just implement a new one that doesn't format, but I'll wait for some input before getting into it.

Indentation of replaced code might cause some challenge.

@github-actions
Copy link

  • Surviving mutants in this change: 11
  • Killed mutants in this change: 61
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.MemberOrdering 11 61

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie rickie self-requested a review May 23, 2023 14:51
@benhalasi benhalasi force-pushed the benhalasi/sort-members-constructors-methods branch from ca7ada8 to 11816d9 Compare May 24, 2023 12:59
@github-actions
Copy link

  • Surviving mutants in this change: 11
  • Killed mutants in this change: 61
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.MemberOrdering 11 61

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link
Member

@rickie rickie left a comment

Choose a reason for hiding this comment

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

There were some imports from ASTHelpers that we usually do not statically import :).

Added a commit! The setup looks nice, didn't get till the end, but already flushing my comments 😄.

@github-actions
Copy link

  • Surviving mutants in this change: 11
  • Killed mutants in this change: 61
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.MemberOrdering 11 61

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie
Copy link
Member

rickie commented May 25, 2023

(Okay apparently I had to rebuild, the test locally passed 😄, will take a look).

I didn't test if MemberOrdering respects annotations, I assumed annotations are part of the member Tree.

@benhalasi I would add a testcase with an annotation in that case 😉 .

I'm not sure how to approach verifying that this checker doesn't mess with whitespaces - as it's hard to test something it shouldn't do - I'm leaning towards to have a separate test method that has all the whitespace cases we want to test, which I'd need input on - and have the other cases properly formatted.

When using the suppression for ErrorProneTestHelperSourceFormat it should be fine to test the whitespaces right?

@sonarcloud
Copy link

sonarcloud bot commented May 25, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

91.5% 91.5% Coverage
0.0% 0.0% Duplication

@github-actions
Copy link

  • Surviving mutants in this change: 11
  • Killed mutants in this change: 61
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.MemberOrdering 11 61

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie
Copy link
Member

rickie commented May 25, 2023

I reverted the commit as I'd need some more time to properly fix this. I'm wondering however, maybe we should use a different method altogether. In the SourceCode file and in our recently moved StringLocaleUsage check (see here), we have examples of going over the ErrorProneTokens.getTokens. Maybe we should use that to get "the full Tree" that we need to replace. I'm not sure which direction is currently the best way to go in.

@benhalasi benhalasi force-pushed the benhalasi/sort-members-constructors-methods branch from 2fcedcd to 291a517 Compare July 8, 2023 17:52
@github-actions
Copy link

github-actions bot commented Jul 8, 2023

  • Surviving mutants in this change: 11
  • Killed mutants in this change: 61
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.MemberOrdering 11 61

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

github-actions bot commented Jul 9, 2023

  • Surviving mutants in this change: 10
  • Killed mutants in this change: 51
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.MemberOrdering 10 49
🎉tech.picnic.errorprone.bugpatterns.MemberOrdering$MemberWithComments 0 2

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

1 similar comment
@github-actions
Copy link

  • Surviving mutants in this change: 10
  • Killed mutants in this change: 51
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.MemberOrdering 10 49
🎉tech.picnic.errorprone.bugpatterns.MemberOrdering$MemberWithComments 0 2

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

  • Surviving mutants in this change: 4
  • Killed mutants in this change: 44
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.MemberOrdering 4 42
🎉tech.picnic.errorprone.bugpatterns.MemberOrdering$ClassMemberWithComments 0 2

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@oxkitsune
Copy link
Contributor

ErrorProneTokens#getTokens(String, Context) doesn't include comments as it relies on the start position of the provided member (e.g., the position of void). Comments don't count as tokens but do affect token positions.

To include comments, we can use VisitorState#getOffsetTokens(int, int) to obtain tokens in a specific range. By starting the range at the end position of the previous token and ending it at the end of the current member, we'll obtain the same tokens, now including comments in the resulting ErrorProneToken.

@github-actions
Copy link

  • Surviving mutants in this change: 4
  • Killed mutants in this change: 44
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.MemberOrdering 4 42
🎉tech.picnic.errorprone.bugpatterns.MemberOrdering$ClassMemberWithComments 0 2

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@benhalasi benhalasi force-pushed the benhalasi/sort-members-constructors-methods branch from ee2cb5e to b0a23ba Compare July 25, 2023 08:17
@github-actions
Copy link

  • Surviving mutants in this change: 4
  • Killed mutants in this change: 44
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.MemberOrdering 4 42
🎉tech.picnic.errorprone.bugpatterns.MemberOrdering$ClassMemberWithComments 0 2

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@benhalasi benhalasi self-assigned this Jul 25, 2023
@github-actions
Copy link

  • Surviving mutants in this change: 5
  • Killed mutants in this change: 50
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.MemberOrdering 5 48
🎉tech.picnic.errorprone.bugpatterns.MemberOrdering$ClassMemberWithComments 0 2

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@benhalasi
Copy link
Contributor Author

benhalasi commented Jul 25, 2023

Thanks oxkitsune for the ErrorProneTokens#getTokens(String, Context)!

Apart from the minor questions below, the only big thing to tackle is verifying that this checker reserves whitespaces or deciding that we don't verify it.

@rickie rickie force-pushed the benhalasi/sort-members-constructors-methods branch from df1d962 to 8d2c426 Compare May 24, 2024 11:25
Copy link

  • Surviving mutants in this change: 15
  • Killed mutants in this change: 69
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.TypeMemberOrder 9 65
🧟tech.picnic.errorprone.utils.MoreASTHelpers 5 0
🧟tech.picnic.errorprone.bugpatterns.TypeMemberOrder$MovableTypeMember 1 4

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link

  • Surviving mutants in this change: 14
  • Killed mutants in this change: 72
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.TypeMemberOrder 8 68
🧟tech.picnic.errorprone.utils.MoreASTHelpers 5 0
🧟tech.picnic.errorprone.bugpatterns.TypeMemberOrder$MovableTypeMember 1 4

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link
Member

@rickie rickie left a comment

Choose a reason for hiding this comment

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

Sorry I didn't put comments everywhere. The main idea behind the changes is that we now do only one "scan" and collect only the members that we can actually change. After that we check is the list sorted, and if not we do the same as before. But now, we know for sure that we only have items that we can and want to switch around :). Makes it a bit easier as we don't need to check for empty/present optionals and have all the data.

So there is still a specific case not working and I didn't finish reviewing all the tests yet, but man this will be an epic check.

Oh and we should still move this to experimental :).

Credits to @Stephan202 as we paired on this.

return Position.NOPOS;
}

/* We return the source code position of the first token that follows the first left brace. */
Copy link
Member

Choose a reason for hiding this comment

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

Didn't go through it with the debugger yet, but we mean the { of the classTree right? In that case we can also say

Suggested change
/* We return the source code position of the first token that follows the first left brace. */
/* Return the source code position of the first token that comes after the first curly bracket. */

`

@benhalasi benhalasi changed the title Introduce ClassMemberOrdering bug checker Introduce TypeMemberOrder bug checker Jun 1, 2024
Copy link

github-actions bot commented Jun 2, 2024

  • Surviving mutants in this change: 14
  • Killed mutants in this change: 51
class surviving killed
🧟tech.picnic.errorprone.experimental.bugpatterns.TypeMemberOrder 13 46
🧟tech.picnic.errorprone.experimental.bugpatterns.TypeMemberOrder$TypeMember 1 5

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link

github-actions bot commented Jun 2, 2024

  • Surviving mutants in this change: 12
  • Killed mutants in this change: 53
class surviving killed
🧟tech.picnic.errorprone.experimental.bugpatterns.TypeMemberOrder 11 48
🧟tech.picnic.errorprone.experimental.bugpatterns.TypeMemberOrder$TypeMember 1 5

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@benhalasi benhalasi force-pushed the benhalasi/sort-members-constructors-methods branch from 2f0bef9 to 50ee382 Compare June 2, 2024 15:03
Copy link

github-actions bot commented Jun 2, 2024

  • Surviving mutants in this change: 12
  • Killed mutants in this change: 53
class surviving killed
🧟tech.picnic.errorprone.experimental.bugpatterns.TypeMemberOrder 11 48
🧟tech.picnic.errorprone.experimental.bugpatterns.TypeMemberOrder$TypeMember 1 5

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link

sonarcloud bot commented Jun 5, 2024

Copy link

github-actions bot commented Jun 5, 2024

  • Surviving mutants in this change: 12
  • Killed mutants in this change: 53
class surviving killed
🧟tech.picnic.errorprone.experimental.bugpatterns.TypeMemberOrder 11 48
🧟tech.picnic.errorprone.experimental.bugpatterns.TypeMemberOrder$TypeMember 1 5

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

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

Successfully merging this pull request may close these issues.

Sort member variables, constructors, and methods
4 participants