Repository: PlasmaFAIR/fortitude (language: python)

Issue:
Rename `external-function` to `procedure-not-in-module`
Then we can rename `external-statement` to `external-procedure`

This would be a breaking change -- best to get it in 0.6.0 and document it


Discussion / hints:

Fix patch:
diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md
new file mode 100644
index 0000000..b2c8050
--- /dev/null
+++ b/BREAKING_CHANGES.md
@@ -0,0 +1,6 @@
+# Breaking Changes
+
+## 0.6.0
+
+- `external-function` has been renamed to the more accurate
+  `procedure-not-in-module`. The rule code is still `M001`.
diff --git a/fortitude/src/rules/mod.rs b/fortitude/src/rules/mod.rs
index 9a9ded2..9fcab76 100644
--- a/fortitude/src/rules/mod.rs
+++ b/fortitude/src/rules/mod.rs
@@ -96,7 +96,7 @@ pub fn code_to_rule(category: Category, code: &str) -> Option<(RuleGroup, Rule)>
         (Typing, "042") => (RuleGroup::Stable, Ast, typing::assumed_size::AssumedSizeCharacterIntent),
         (Typing, "043") => (RuleGroup::Stable, Ast, typing::assumed_size::DeprecatedAssumedSizeCharacter),
         (Typing, "051") => (RuleGroup::Stable, Ast, typing::init_decls::InitialisationInDeclaration),
-        (Typing, "061") => (RuleGroup::Preview, Ast, typing::external::ExternalStatement),
+        (Typing, "061") => (RuleGroup::Preview, Ast, typing::external::ExternalProcedure),
 
         (Obsolescent, "001") => (RuleGroup::Preview, Ast, obsolescent::statement_functions::StatementFunction),
         (Obsolescent, "011") => (RuleGroup::Preview, Ast, obsolescent::common_blocks::CommonBlock),
@@ -106,7 +106,7 @@ pub fn code_to_rule(category: Category, code: &str) -> Option<(RuleGroup, Rule)>
         (Precision, "011") => (RuleGroup::Stable, Ast, precision::double_precision::DoublePrecision),
         (Precision, "021") => (RuleGroup::Stable, Ast, precision::implicit_kinds::ImplicitRealKind),
 
-        (Modules, "001") => (RuleGroup::Stable, Ast, modules::external_functions::ExternalFunction),
+        (Modules, "001") => (RuleGroup::Stable, Ast, modules::external_functions::ProcedureNotInModule),
         (Modules, "011") => (RuleGroup::Stable, Ast, modules::use_statements::UseAll),
         (Modules, "021") => (RuleGroup::Preview, Ast, modules::accessibility_statements::MissingAccessibilityStatement),
         (Modules, "022") => (RuleGroup::Preview, Ast, modules::accessibility_statements::DefaultPublicAccessibility),
diff --git a/fortitude/src/rules/modules/external_functions.rs b/fortitude/src/rules/modules/external_functions.rs
index 33dbaf3..592c5f7 100644
--- a/fortitude/src/rules/modules/external_functions.rs
+++ b/fortitude/src/rules/modules/external_functions.rs
@@ -14,25 +14,25 @@ use tree_sitter::Node;
 /// Fortran compilers are unable to perform type checks and conversions on functions
 /// defined outside of these scopes, and this is a common source of bugs.
 #[violation]
-pub struct ExternalFunction {
+pub struct ProcedureNotInModule {
     procedure: String,
 }
 
-impl Violation for ExternalFunction {
+impl Violation for ProcedureNotInModule {
     #[derive_message_formats]
     fn message(&self) -> String {
-        let ExternalFunction { procedure } = self;
+        let ProcedureNotInModule { procedure } = self;
         format!("{procedure} not contained within (sub)module or program")
     }
 }
 
-impl AstRule for ExternalFunction {
+impl AstRule for ProcedureNotInModule {
     fn check(_settings: &Settings, node: &Node, _src: &SourceFile) -> Option<Vec<Diagnostic>> {
         if node.parent()?.kind() == "translation_unit" {
             let procedure_stmt = node.child(0)?;
             let procedure = node.kind().to_string();
             return some_vec![Diagnostic::from_node(
-                ExternalFunction { procedure },
+                ProcedureNotInModule { procedure },
                 &procedure_stmt
             )];
         }
diff --git a/fortitude/src/rules/modules/mod.rs b/fortitude/src/rules/modules/mod.rs
index b335e7b..972e360 100644
--- a/fortitude/src/rules/modules/mod.rs
+++ b/fortitude/src/rules/modules/mod.rs
@@ -19,7 +19,7 @@ mod tests {
     use crate::settings::Settings;
     use crate::test::test_path;
 
-    #[test_case(Rule::ExternalFunction, Path::new("M001.f90"))]
+    #[test_case(Rule::ProcedureNotInModule, Path::new("M001.f90"))]
     #[test_case(Rule::UseAll, Path::new("M011.f90"))]
     #[test_case(Rule::MissingAccessibilityStatement, Path::new("M021.f90"))]
     #[test_case(Rule::DefaultPublicAccessibility, Path::new("M022.f90"))]
diff --git a/fortitude/src/rules/typing/external.rs b/fortitude/src/rules/typing/external.rs
index f509747..96b6f8b 100644
--- a/fortitude/src/rules/typing/external.rs
+++ b/fortitude/src/rules/typing/external.rs
@@ -15,11 +15,11 @@ use crate::{ast::FortitudeNode, settings::Settings, AstRule, FromAstNode};
 /// If the procedure is in your project, put it in a module (see
 /// `external-function`), or write an explicit interface.
 #[violation]
-pub struct ExternalStatement {
+pub struct ExternalProcedure {
     name: String,
 }
 
-impl Violation for ExternalStatement {
+impl Violation for ExternalProcedure {
     #[derive_message_formats]
     fn message(&self) -> String {
         let Self { name } = self;
@@ -31,7 +31,7 @@ impl Violation for ExternalStatement {
     }
 }
 
-impl AstRule for ExternalStatement {
+impl AstRule for ExternalProcedure {
     fn check(_settings: &Settings, node: &Node, source: &SourceFile) -> Option<Vec<Diagnostic>> {
         if node
             .child_with_name("type_qualifier")?
diff --git a/fortitude/src/rules/typing/mod.rs b/fortitude/src/rules/typing/mod.rs
index 99a2fd8..d729281 100644
--- a/fortitude/src/rules/typing/mod.rs
+++ b/fortitude/src/rules/typing/mod.rs
@@ -31,7 +31,7 @@ mod tests {
     #[test_case(Rule::AssumedSizeCharacterIntent, Path::new("T042.f90"))]
     #[test_case(Rule::DeprecatedAssumedSizeCharacter, Path::new("T043.f90"))]
     #[test_case(Rule::InitialisationInDeclaration, Path::new("T051.f90"))]
-    #[test_case(Rule::ExternalStatement, Path::new("T061.f90"))]
+    #[test_case(Rule::ExternalProcedure, Path::new("T061.f90"))]
     fn rules(rule_code: Rule, path: &Path) -> Result<()> {
         let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
         let diagnostics = test_path(


Test patch:
diff --git a/fortitude/src/rules/modules/snapshots/fortitude__rules__modules__tests__external-function_M001.f90.snap b/fortitude/src/rules/modules/snapshots/fortitude__rules__modules__tests__procedure-not-in-module_M001.f90.snap
similarity index 100%
rename from fortitude/src/rules/modules/snapshots/fortitude__rules__modules__tests__external-function_M001.f90.snap
rename to fortitude/src/rules/modules/snapshots/fortitude__rules__modules__tests__procedure-not-in-module_M001.f90.snap
diff --git a/fortitude/src/rules/typing/snapshots/fortitude__rules__typing__tests__external-statement_T061.f90.snap b/fortitude/src/rules/typing/snapshots/fortitude__rules__typing__tests__external-procedure_T061.f90.snap
similarity index 100%
rename from fortitude/src/rules/typing/snapshots/fortitude__rules__typing__tests__external-statement_T061.f90.snap
rename to fortitude/src/rules/typing/snapshots/fortitude__rules__typing__tests__external-procedure_T061.f90.snap