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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions cli/tools/lint/mod.rs
Expand Up @@ -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;
Expand All @@ -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";
Expand Down Expand Up @@ -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 = Arc::new(Mutex::new(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 {
Expand Down Expand Up @@ -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?

let linter = linter.clone();
Comment on lines 222 to +223
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.

let reporter_lock = reporter_lock.clone();
let incremental_cache = incremental_cache.clone();
let fix = lint_options.fix;
Expand Down