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

Unify duplicate code detection with code reimplementations #648

Open
Luro02 opened this issue Nov 28, 2024 · 0 comments
Open

Unify duplicate code detection with code reimplementations #648

Luro02 opened this issue Nov 28, 2024 · 0 comments
Labels
api lints that check for code that reimplements parts of the api D-hard duplicate-code enhancement New feature or request high-priority Issues that should be solved as soon as possible

Comments

@Luro02
Copy link
Collaborator

Luro02 commented Nov 28, 2024

Description

Motivation

The duplicate code detection is used to detect pieces of code that are mostly the same, except for maybe a few places where they differ.

A very similar problem is the detection of code that already exists in the standard library. The associated checks are mostly in the api package.

Most of them are implemented like this:

  1. Find common code patterns in submissions
  2. Write code that detects the above common code patterns

This is effectively doing the duplicate code detection, but manually. One could speed up the process for new checks, by reusing the duplicate code check and by further improving the duplicate code detection, one would improve the api checks as well.

Benefits

  • faster to implement new checks
  • makes a lot more sense to detect niche patterns like Suggest using contains (or Arrays.asList(....).contains) #620, where it is questionable if they are worth the effort
  • any improvements will improve many more checks
  • especially the duplicate code detection will benefit from it. Currently it is questionable whether any more work in duplicate code detection is worth the effort, but with this, one can invest a lot of time and will have substantial benefits
  • code base should shrink
  • code will become easier to read, because it would detach reimplementation checks from spoon

Disadvantages

  • Depending on the check, it might be too generic.
  • Duplicate Code detection is by far the slowest check, this might make it worse.
  • There is a chance that this will not work out.
@Luro02 Luro02 added enhancement New feature or request D-hard api lints that check for code that reimplements parts of the api duplicate-code high-priority Issues that should be solved as soon as possible labels Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api lints that check for code that reimplements parts of the api D-hard duplicate-code enhancement New feature or request high-priority Issues that should be solved as soon as possible
Projects
None yet
Development

No branches or pull requests

1 participant