Skip to content

Commit

Permalink
chore: switch to Rustfmt 2024 style edition (#5236)
Browse files Browse the repository at this point in the history
  • Loading branch information
siketyan authored Mar 2, 2025
1 parent bf675cf commit 9b2d5db
Show file tree
Hide file tree
Showing 1,076 changed files with 9,969 additions and 2,511 deletions.
2 changes: 1 addition & 1 deletion crates/biome_analyze/src/categories.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use enumflags2::{bitflags, BitFlags};
use enumflags2::{BitFlags, bitflags};
use std::borrow::Cow;
use std::fmt::{Display, Formatter};

Expand Down
2 changes: 1 addition & 1 deletion crates/biome_analyze/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::options::{JsxRuntime, PreferredQuote};
use crate::{registry::RuleRoot, FromServices, Queryable, Rule, RuleKey, ServiceBag};
use crate::{FromServices, Queryable, Rule, RuleKey, ServiceBag, registry::RuleRoot};
use crate::{GroupCategory, RuleCategory, RuleGroup, RuleMetadata};
use biome_diagnostics::{Error, Result};
use camino::Utf8Path;
Expand Down
6 changes: 3 additions & 3 deletions crates/biome_analyze/src/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use biome_console::{markup, MarkupBuf};
use biome_console::{MarkupBuf, markup};
use biome_diagnostics::{
advice::CodeSuggestionAdvice, category, Advices, Category, Diagnostic, DiagnosticExt,
DiagnosticTags, Error, Location, LogCategory, MessageAndDescription, Severity, Visit,
Advices, Category, Diagnostic, DiagnosticExt, DiagnosticTags, Error, Location, LogCategory,
MessageAndDescription, Severity, Visit, advice::CodeSuggestionAdvice, category,
};
use biome_rowan::TextRange;
use std::borrow::Cow;
Expand Down
12 changes: 6 additions & 6 deletions crates/biome_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ pub use biome_diagnostics::category_concat;
pub use crate::analyzer_plugin::{AnalyzerPlugin, AnalyzerPluginSlice, AnalyzerPluginVec};
pub use crate::categories::{
ActionCategory, OtherActionCategory, RefactorKind, RuleCategories, RuleCategoriesBuilder,
RuleCategory, SourceActionKind, SUPPRESSION_INLINE_ACTION_CATEGORY,
SUPPRESSION_TOP_LEVEL_ACTION_CATEGORY,
RuleCategory, SUPPRESSION_INLINE_ACTION_CATEGORY, SUPPRESSION_TOP_LEVEL_ACTION_CATEGORY,
SourceActionKind,
};
pub use crate::diagnostics::{AnalyzerDiagnostic, AnalyzerSuppressionDiagnostic, RuleError};
pub use crate::matcher::{InspectMatcher, MatchQueryParams, QueryMatcher, RuleKey, SignalEntry};
Expand All @@ -52,7 +52,7 @@ pub use crate::signals::{
use crate::suppressions::Suppressions;
pub use crate::syntax::{Ast, SyntaxVisitor};
pub use crate::visitor::{NodeVisitor, Visitor, VisitorContext, VisitorFinishContext};
use biome_diagnostics::{category, Diagnostic, DiagnosticExt};
use biome_diagnostics::{Diagnostic, DiagnosticExt, category};
use biome_rowan::{
AstNode, BatchMutation, Direction, Language, SyntaxElement, SyntaxToken, TextRange, TextSize,
TokenAtOffset, TriviaPieceKind, WalkEvent,
Expand Down Expand Up @@ -280,9 +280,9 @@ where
)
} else {
AnalyzerSuppressionDiagnostic::new(
category!("suppressions/unused"),
suppression.comment_span,
"Suppression comment has no effect. Remove the suppression or make sure you are suppressing the correct rule.",
category!("suppressions/unused"),
suppression.comment_span,
"Suppression comment has no effect. Remove the suppression or make sure you are suppressing the correct rule.",
)
}
});
Expand Down
10 changes: 5 additions & 5 deletions crates/biome_analyze/src/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,16 @@ where
mod tests {
use super::MatchQueryParams;
use crate::{
signals::DiagnosticSignal, Analyzer, AnalyzerContext, AnalyzerSignal, ApplySuppression,
ControlFlow, MetadataRegistry, Never, Phases, QueryMatcher, RuleKey, ServiceBag,
SignalEntry, SuppressionAction, SyntaxVisitor,
Analyzer, AnalyzerContext, AnalyzerSignal, ApplySuppression, ControlFlow, MetadataRegistry,
Never, Phases, QueryMatcher, RuleKey, ServiceBag, SignalEntry, SuppressionAction,
SyntaxVisitor, signals::DiagnosticSignal,
};
use crate::{AnalyzerOptions, AnalyzerSuppression};
use biome_diagnostics::{category, DiagnosticExt};
use biome_diagnostics::{Diagnostic, Severity};
use biome_diagnostics::{DiagnosticExt, category};
use biome_rowan::{
raw_language::{RawLanguage, RawLanguageKind, RawLanguageRoot, RawSyntaxTreeBuilder},
AstNode, BatchMutation, SyntaxNode, SyntaxToken, TextRange, TextSize, TriviaPiece,
raw_language::{RawLanguage, RawLanguageKind, RawLanguageRoot, RawSyntaxTreeBuilder},
};
use std::convert::Infallible;

Expand Down
2 changes: 1 addition & 1 deletion crates/biome_analyze/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::any::TypeId;

use biome_rowan::{Language, SyntaxKindSet, TextRange};

use crate::{registry::Phase, services::FromServices, Phases, ServiceBag, Visitor};
use crate::{Phases, ServiceBag, Visitor, registry::Phase, services::FromServices};

/// Trait implemented for types that lint rules can query in order to emit diagnostics or code actions.
pub trait Queryable: Sized {
Expand Down
12 changes: 8 additions & 4 deletions crates/biome_analyze/src/registry.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{
AddVisitor, AnalysisFilter, GroupCategory, QueryMatcher, Rule, RuleGroup, RuleKey,
RuleMetadata, ServiceBag, SignalEntry, Visitor,
context::RuleContext,
matcher::{GroupKey, MatchQueryParams},
query::{QueryKey, Queryable},
signals::RuleSignal,
AddVisitor, AnalysisFilter, GroupCategory, QueryMatcher, Rule, RuleGroup, RuleKey,
RuleMetadata, ServiceBag, SignalEntry, Visitor,
};
use biome_diagnostics::Error;
use biome_rowan::{AstNode, Language, RawSyntaxKind, SyntaxKind, SyntaxNode};
Expand Down Expand Up @@ -179,7 +179,9 @@ impl<L: Language + Default + 'static> RegistryVisitor<L> for RuleRegistryBuilder
.entry(TypeId::of::<SyntaxNode<L>>())
.or_insert_with(|| TypeRules::SyntaxRules { rules: Vec::new() })
else {
unreachable!("the SyntaxNode type has already been registered as a TypeRules instead of a SyntaxRules, this is generally caused by an implementation of `Queryable::key` returning a `QueryKey::TypeId` with the type ID of `SyntaxNode`")
unreachable!(
"the SyntaxNode type has already been registered as a TypeRules instead of a SyntaxRules, this is generally caused by an implementation of `Queryable::key` returning a `QueryKey::TypeId` with the type ID of `SyntaxNode`"
)
};

// Iterate on all the SyntaxKind variants this node can match
Expand Down Expand Up @@ -207,7 +209,9 @@ impl<L: Language + Default + 'static> RegistryVisitor<L> for RuleRegistryBuilder
.entry(key)
.or_insert_with(|| TypeRules::TypeRules { rules: Vec::new() })
else {
unreachable!("the query type has already been registered as a SyntaxRules instead of a TypeRules, this is generally caused by an implementation of `Queryable::key` returning a `QueryKey::TypeId` with the type ID of `SyntaxNode`")
unreachable!(
"the query type has already been registered as a SyntaxRules instead of a TypeRules, this is generally caused by an implementation of `Queryable::key` returning a `QueryKey::TypeId` with the type ID of `SyntaxNode`"
)
};

rules.push(rule);
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_analyze/src/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
Phase, Phases, Queryable, SourceActionKind, SuppressionAction, SuppressionCommentEmitterPayload,
};
use biome_console::fmt::{Display, Formatter};
use biome_console::{markup, MarkupBuf, Padding};
use biome_console::{MarkupBuf, Padding, markup};
use biome_diagnostics::advice::CodeSuggestionAdvice;
use biome_diagnostics::location::AsSpan;
use biome_diagnostics::{
Expand Down
6 changes: 3 additions & 3 deletions crates/biome_analyze/src/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ use crate::categories::{
SUPPRESSION_INLINE_ACTION_CATEGORY, SUPPRESSION_TOP_LEVEL_ACTION_CATEGORY,
};
use crate::{
AnalyzerDiagnostic, AnalyzerOptions, OtherActionCategory, Queryable, RuleGroup, ServiceBag,
SuppressionAction,
categories::ActionCategory,
context::RuleContext,
registry::{RuleLanguage, RuleRoot},
rule::Rule,
AnalyzerDiagnostic, AnalyzerOptions, OtherActionCategory, Queryable, RuleGroup, ServiceBag,
SuppressionAction,
};
use biome_console::MarkupBuf;
use biome_diagnostics::{advice::CodeSuggestionAdvice, Applicability, CodeSuggestion, Error};
use biome_diagnostics::{Applicability, CodeSuggestion, Error, advice::CodeSuggestionAdvice};
use biome_rowan::{BatchMutation, Language};
use std::iter::FusedIterator;
use std::marker::PhantomData;
Expand Down
12 changes: 6 additions & 6 deletions crates/biome_analyze/src/syntax.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use biome_rowan::{AstNode, Language, SyntaxNode, WalkEvent};

use crate::{
registry::NodeLanguage, AddVisitor, Phases, QueryKey, QueryMatch, Queryable, ServiceBag,
Visitor, VisitorContext,
AddVisitor, Phases, QueryKey, QueryMatch, Queryable, ServiceBag, Visitor, VisitorContext,
registry::NodeLanguage,
};

/// Query type usable by lint rules to match on specific [AstNode] types
Expand Down Expand Up @@ -93,15 +93,15 @@ impl<L: Language + 'static> Visitor for SyntaxVisitor<L> {
#[cfg(test)]
mod tests {
use biome_rowan::{
raw_language::{RawLanguage, RawLanguageKind, RawLanguageRoot, RawSyntaxTreeBuilder},
AstNode, BatchMutation, SyntaxNode, SyntaxToken,
raw_language::{RawLanguage, RawLanguageKind, RawLanguageRoot, RawSyntaxTreeBuilder},
};
use std::convert::Infallible;

use crate::{
matcher::MatchQueryParams, registry::Phases, Analyzer, AnalyzerContext, AnalyzerOptions,
AnalyzerSignal, ApplySuppression, ControlFlow, MetadataRegistry, Never, QueryMatcher,
ServiceBag, SuppressionAction, SyntaxVisitor,
Analyzer, AnalyzerContext, AnalyzerOptions, AnalyzerSignal, ApplySuppression, ControlFlow,
MetadataRegistry, Never, QueryMatcher, ServiceBag, SuppressionAction, SyntaxVisitor,
matcher::MatchQueryParams, registry::Phases,
};

#[derive(Default)]
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_analyze/src/visitor.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::{
matcher::{MatchQueryParams, Query},
registry::{NodeLanguage, Phases},
AnalyzerOptions, LanguageRoot, QueryMatch, QueryMatcher, ServiceBag, SignalEntry,
SuppressionAction,
matcher::{MatchQueryParams, Query},
registry::{NodeLanguage, Phases},
};
use biome_rowan::{AstNode, Language, SyntaxNode, TextRange, WalkEvent};
use std::collections::BinaryHeap;
Expand Down
6 changes: 5 additions & 1 deletion crates/biome_cli/src/changed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ pub(crate) fn get_changed_files(
(Some(since), Some(_)) => since,
(Some(since), None) => since,
(None, Some(branch)) => branch,
(None, None) => return Err(CliDiagnostic::incompatible_end_configuration("The `--changed` flag was set, but Biome couldn't determine the base to compare against. Either set configuration.vcs.defaultBranch or use the --since argument.")),
(None, None) => {
return Err(CliDiagnostic::incompatible_end_configuration(
"The `--changed` flag was set, but Biome couldn't determine the base to compare against. Either set configuration.vcs.defaultBranch or use the --since argument.",
));
}
};

let changed_files = fs.get_changed_files(base)?;
Expand Down
7 changes: 5 additions & 2 deletions crates/biome_cli/src/cli_options.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::logging::LoggingKind;
use crate::LoggingLevel;
use crate::logging::LoggingKind;
use biome_configuration::ConfigurationPathHint;
use biome_diagnostics::Severity;
use bpaf::Bpaf;
Expand Down Expand Up @@ -216,7 +216,10 @@ impl FromStr for MaxDiagnostics {
if let Ok(value) = s.parse::<u32>() {
Ok(MaxDiagnostics::Limit(value))
} else {
Err(format!("Invalid value provided. Provide 'none' to lift the limit, or a number between 0 and {}.", u32::MAX))
Err(format!(
"Invalid value provided. Provide 'none' to lift the limit, or a number between 0 and {}.",
u32::MAX
))
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/biome_cli/src/commands/check.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use super::{determine_fix_file_mode, FixFileModeOptions, LoadEditorConfig};
use super::{FixFileModeOptions, LoadEditorConfig, determine_fix_file_mode};
use crate::cli_options::CliOptions;
use crate::commands::{get_files_to_process_with_cli_options, CommandRunner};
use crate::commands::{CommandRunner, get_files_to_process_with_cli_options};
use crate::{CliDiagnostic, Execution, TraversalMode};
use biome_configuration::analyzer::assist::{AssistConfiguration, AssistEnabled};
use biome_configuration::analyzer::LinterEnabled;
use biome_configuration::analyzer::assist::{AssistConfiguration, AssistEnabled};
use biome_configuration::formatter::FormatterEnabled;
use biome_configuration::{Configuration, FormatterConfiguration, LinterConfiguration};
use biome_console::Console;
use biome_deserialize::Merge;
use biome_fs::FileSystem;
use biome_service::projects::ProjectKey;
use biome_service::{configuration::LoadedConfiguration, Workspace, WorkspaceError};
use biome_service::{Workspace, WorkspaceError, configuration::LoadedConfiguration};
use std::ffi::OsString;

pub(crate) struct CheckCommandPayload {
Expand Down
6 changes: 4 additions & 2 deletions crates/biome_cli/src/commands/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::changed::get_changed_files;
use crate::cli_options::CliOptions;
use crate::commands::{CommandRunner, LoadEditorConfig};
use crate::{CliDiagnostic, Execution};
use biome_configuration::analyzer::assist::{AssistConfiguration, AssistEnabled};
use biome_configuration::analyzer::LinterEnabled;
use biome_configuration::analyzer::assist::{AssistConfiguration, AssistEnabled};
use biome_configuration::formatter::FormatterEnabled;
use biome_configuration::{Configuration, FormatterConfiguration, LinterConfiguration};
use biome_console::Console;
Expand Down Expand Up @@ -126,7 +126,9 @@ impl CommandRunner for CiCommandPayload {
&& self.linter_enabled.is_some_and(|v| !v.value())
&& self.assist_enabled.is_some_and(|v| !v.value())
{
return Err(CliDiagnostic::incompatible_end_configuration("Formatter, linter and assist are disabled, can't perform the command. At least one feature needs to be enabled. This is probably and error."));
return Err(CliDiagnostic::incompatible_end_configuration(
"Formatter, linter and assist are disabled, can't perform the command. At least one feature needs to be enabled. This is probably and error.",
));
}
if self.since.is_some() && !self.changed {
return Err(CliDiagnostic::incompatible_arguments("since", "changed"));
Expand Down
12 changes: 6 additions & 6 deletions crates/biome_cli/src/commands/daemon.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
use crate::{
open_transport,
CliDiagnostic, CliSession, open_transport,
service::{self, ensure_daemon, open_socket, run_daemon},
CliDiagnostic, CliSession,
};
use biome_console::{markup, ConsoleExt};
use biome_console::{ConsoleExt, markup};
use biome_fs::OsFileSystem;
use biome_lsp::ServerFactory;
use biome_service::{workspace::WorkspaceClient, TransportError, WorkspaceError, WorkspaceWatcher};
use biome_service::{TransportError, WorkspaceError, WorkspaceWatcher, workspace::WorkspaceClient};
use camino::{Utf8Path, Utf8PathBuf};
use std::{env, fs};
use tokio::io;
use tokio::runtime::Runtime;
use tracing::subscriber::Interest;
use tracing::{debug_span, metadata::LevelFilter, Instrument, Metadata};
use tracing::{Instrument, Metadata, debug_span, metadata::LevelFilter};
use tracing_appender::rolling::Rotation;
use tracing_subscriber::{
Layer,
layer::{Context, Filter},
prelude::*,
registry, Layer,
registry,
};
use tracing_tree::HierarchicalLayer;

Expand Down
2 changes: 1 addition & 1 deletion crates/biome_cli/src/commands/explain.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use biome_analyze::RuleMetadata;
use biome_console::{markup, ConsoleExt};
use biome_console::{ConsoleExt, markup};
use biome_flags::biome_env;
use biome_service::documentation::Doc;

Expand Down
2 changes: 1 addition & 1 deletion crates/biome_cli/src/commands/format.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::cli_options::CliOptions;
use crate::commands::{get_files_to_process_with_cli_options, CommandRunner, LoadEditorConfig};
use crate::commands::{CommandRunner, LoadEditorConfig, get_files_to_process_with_cli_options};
use crate::{CliDiagnostic, Execution, TraversalMode};
use biome_configuration::css::CssFormatterConfiguration;
use biome_configuration::graphql::GraphqlFormatterConfiguration;
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_cli/src/commands/init.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{CliDiagnostic, CliSession};
use biome_configuration::Configuration;
use biome_console::{markup, ConsoleExt};
use biome_console::{ConsoleExt, markup};
use biome_fs::ConfigName;
use biome_service::configuration::create_config;

Expand Down
4 changes: 2 additions & 2 deletions crates/biome_cli/src/commands/lint.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{determine_fix_file_mode, FixFileModeOptions};
use super::{FixFileModeOptions, determine_fix_file_mode};
use crate::cli_options::CliOptions;
use crate::commands::{get_files_to_process_with_cli_options, CommandRunner};
use crate::commands::{CommandRunner, get_files_to_process_with_cli_options};
use crate::{CliDiagnostic, Execution, TraversalMode};
use biome_configuration::analyzer::RuleSelector;
use biome_configuration::css::CssLinterConfiguration;
Expand Down
6 changes: 3 additions & 3 deletions crates/biome_cli/src/commands/migrate.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::{
check_fix_incompatible_arguments, CommandRunner, FixFileModeOptions, MigrateSubCommand,
CommandRunner, FixFileModeOptions, MigrateSubCommand, check_fix_incompatible_arguments,
};
use crate::CliDiagnostic;
use crate::cli_options::CliOptions;
use crate::diagnostics::MigrationDiagnostic;
use crate::execute::{Execution, TraversalMode};
use crate::CliDiagnostic;
use biome_configuration::Configuration;
use biome_console::{markup, Console, ConsoleExt};
use biome_console::{Console, ConsoleExt, markup};
use biome_fs::FileSystem;
use biome_service::configuration::LoadedConfiguration;
use biome_service::projects::ProjectKey;
Expand Down
Loading

0 comments on commit 9b2d5db

Please sign in to comment.