-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
wooseok123
wants to merge
3
commits into
denoland:main
Choose a base branch
from
wooseok123:refactor-lint
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ use std::path::Path; | |
use std::path::PathBuf; | ||
use std::sync::Arc; | ||
|
||
|
||
use crate::args::CliOptions; | ||
use crate::args::Flags; | ||
use crate::args::LintFlags; | ||
|
@@ -51,6 +52,7 @@ use crate::util::fs::FileCollector; | |
use crate::util::path::is_script_ext; | ||
use crate::util::sync::AtomicFlag; | ||
|
||
|
||
pub mod no_slow_types; | ||
|
||
static STDIN_FILE_NAME: &str = "$deno$stdin.ts"; | ||
|
@@ -173,7 +175,7 @@ async fn lint_files( | |
let reporter_lock = | ||
Arc::new(Mutex::new(create_reporter(reporter_kind.clone()))); | ||
let has_error = Arc::new(AtomicFlag::default()); | ||
|
||
let linter = create_linter(lint_rules.clone()); | ||
let mut futures = Vec::with_capacity(2); | ||
if lint_rules.no_slow_types { | ||
if let Some(config_file) = maybe_config_file { | ||
|
@@ -218,7 +220,7 @@ async fn lint_files( | |
|
||
futures.push({ | ||
let has_error = has_error.clone(); | ||
let linter = create_linter(lint_rules.rules); | ||
let linter = linter.clone(); | ||
Comment on lines
222
to
+223
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
let reporter_lock = reporter_lock.clone(); | ||
let incremental_cache = incremental_cache.clone(); | ||
let fix = lint_options.fix; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?