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 51 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?

@sonarqubecloud
Copy link

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.

Copy link

github-actions bot commented Dec 4, 2024

  • Surviving mutants in this change: 11
  • Killed mutants in this change: 82
class surviving killed
🧟tech.picnic.errorprone.experimental.bugpatterns.TypeMemberOrder 11 81
🎉tech.picnic.errorprone.experimental.bugpatterns.TypeMemberOrder$TypeMember 0 1

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 f84a759 to 47e27eb Compare December 4, 2024 08:23
Copy link

github-actions bot commented Dec 4, 2024

  • Surviving mutants in this change: 16
  • Killed mutants in this change: 82
class surviving killed
🧟tech.picnic.errorprone.experimental.bugpatterns.TypeMemberOrder 11 81
🧟tech.picnic.errorprone.utils.MoreASTHelpers 5 0
🎉tech.picnic.errorprone.experimental.bugpatterns.TypeMemberOrder$TypeMember 0 1

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

Copy link

github-actions bot commented Dec 7, 2024

  • Surviving mutants in this change: 15
  • Killed mutants in this change: 84
class surviving killed
🧟tech.picnic.errorprone.experimental.bugpatterns.TypeMemberOrder 10 82
🧟tech.picnic.errorprone.utils.MoreASTHelpers 5 0
🎉tech.picnic.errorprone.experimental.bugpatterns.TypeMemberOrder$TypeMember 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 dc1f77b to 0bc5f94 Compare December 7, 2024 10:38
Copy link

github-actions bot commented Dec 7, 2024

  • Surviving mutants in this change: 15
  • Killed mutants in this change: 84
class surviving killed
🧟tech.picnic.errorprone.experimental.bugpatterns.TypeMemberOrder 10 82
🧟tech.picnic.errorprone.utils.MoreASTHelpers 5 0
🎉tech.picnic.errorprone.experimental.bugpatterns.TypeMemberOrder$TypeMember 0 2

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

@rickie
Copy link
Member

rickie commented Dec 7, 2024

/integration-test

1 similar comment
@benhalasi
Copy link
Contributor Author

/integration-test

@rickie
Copy link
Member

rickie commented Dec 10, 2024

It's not working as this check is in the experimental module 😬. So we will need to tweak something, or to run it locally 😄 @benhalasi.

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