refactor: Rename RuleOrigin::title to RuleOrigin::name

This commit is contained in:
Martin Fischer 2023-01-17 06:02:53 +01:00 committed by Charlie Marsh
parent f4da7635f0
commit 601848d9a8
3 changed files with 7 additions and 7 deletions

View File

@ -296,7 +296,7 @@ pub fn explain(code: &RuleCode, format: SerializationFormat) -> Result<()> {
println!(
"{} ({}): {}",
code.as_ref(),
code.origin().title(),
code.origin().name(),
code.kind().summary()
);
}
@ -305,7 +305,7 @@ pub fn explain(code: &RuleCode, format: SerializationFormat) -> Result<()> {
"{}",
serde_json::to_string_pretty(&Explanation {
code: code.as_ref(),
origin: code.origin().title(),
origin: code.origin().name(),
summary: &code.kind().summary(),
})?
);

View File

@ -47,22 +47,22 @@ pub fn main(cli: &Cli) -> Result<()> {
for origin in RuleOrigin::iter() {
let prefixes = origin.prefixes();
let codes_csv: String = prefixes.as_list(", ");
table_out.push_str(&format!("### {} ({codes_csv})", origin.title()));
table_out.push_str(&format!("### {} ({codes_csv})", origin.name()));
table_out.push('\n');
table_out.push('\n');
toc_out.push_str(&format!(
" 1. [{} ({})](#{}-{})\n",
origin.title(),
origin.name(),
codes_csv,
origin.title().to_lowercase().replace(' ', "-"),
origin.name().to_lowercase().replace(' ', "-"),
codes_csv.to_lowercase().replace(',', "-").replace(' ', "")
));
if let Some((url, platform)) = origin.url() {
table_out.push_str(&format!(
"For more, see [{}]({}) on {}.",
origin.title(),
origin.name(),
url,
platform
));

View File

@ -495,7 +495,7 @@ impl Prefixes {
}
impl RuleOrigin {
pub fn title(&self) -> &'static str {
pub fn name(&self) -> &'static str {
match self {
RuleOrigin::Eradicate => "eradicate",
RuleOrigin::Flake82020 => "flake8-2020",