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

refactor: redundancy of creating lint instance #23308

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

wooseok123
Copy link

Related issue : #21876

I tried to make a singleton of linter instance so that it can be reused. But it's still on progress.

@CLAassistant
Copy link

CLAassistant commented Apr 10, 2024

CLA assistant check
All committers have signed the CLA.

@wooseok123 wooseok123 changed the title refactor : redundant of creating lint instance refactor : redundancy of creating lint instance Apr 10, 2024
Comment on lines 61 to 63
lazy_static! {
static ref LINTER: Mutex<Option<Linter>> = Mutex::new(None);
}
Copy link
Member

Choose a reason for hiding this comment

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

This seems redundant, you can create it directly in lint_files function

Comment on lines 222 to +223
let has_error = has_error.clone();
let linter = create_linter(lint_rules.rules);
let linter = linter.clone();
Copy link
Author

Choose a reason for hiding this comment

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

@bartlomieju This might works? creating an instance outside the future and cloning it when it is used inside the future.

@dsherret dsherret changed the title refactor : redundancy of creating lint instance refactor: redundancy of creating lint instance Apr 10, 2024
@@ -218,7 +220,7 @@ async fn lint_files(

futures.push({
let has_error = has_error.clone();
let linter = create_linter(lint_rules.rules);
Copy link
Member

Choose a reason for hiding this comment

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

This was only created once. #21876 is out of date and already solved

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, sorry @wooseok123, it looks like the previous code below is only creating the linter once for the run_parallelized

Copy link
Author

Choose a reason for hiding this comment

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

Ah, thank you for checking that.
I think it needs to add more test code though.
Making a seperate PR for that would be better?

@bartlomieju bartlomieju added this to the 1.44 milestone May 5, 2024
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

Successfully merging this pull request may close these issues.

None yet

4 participants