pub(crate) fn ban_unused_ignore(
    &self,
    specified_rules: &[Box<dyn LintRule>],
  ) -> Vec<LintDiagnostic> {
    const CODE: &str = "ban-unused-ignore";

    // If there's a file-level ignore directive containing `ban-unused-ignore`,
    // exit without running this rule.
    if self
      .file_ignore_directive
      .as_ref()
      .map_or(false, |file_ignore| file_ignore.has_code(CODE))
    {
      return vec![];
    }

    let executed_builtin_codes: HashSet<&'static str> =
      specified_rules.iter().map(|r| r.code()).collect();
    let is_unused_code = |&(code, status): &(&String, &CodeStatus)| {
      let is_unknown = !executed_builtin_codes.contains(code.as_str())
        && !self.plugin_codes.contains(code.as_str());
      !status.used && !is_unknown
    };

    let mut diagnostics = Vec::new();

    if let Some(file_ignore) = self.file_ignore_directive.as_ref() {
      for (unused_code, _status) in
        file_ignore.codes().iter().filter(is_unused_code)
      {
        let d = self.create_diagnostic(
          file_ignore.span(),
          CODE,
          format!("Ignore for code \"{}\" was not used.", unused_code),
          None,
        );
        diagnostics.push(d);
      }
    }

    for line_ignore in self.line_ignore_directives.values() {
      // We do nothing special even if the line-level ignore directive contains
      // `ban-unused-ignore`. `ban-unused-ignore` can be ignored only via the
      // file-level directive.

      for (unused_code, _status) in
        line_ignore.codes().iter().filter(is_unused_code)
      {
        let d = self.create_diagnostic(
          line_ignore.span(),
          CODE,
          format!("Ignore for code \"{}\" was not used.", unused_code),
          None,
        );
        diagnostics.push(d);
      }
    }

    diagnostics
  }
/// Lint rule implementation for `ban-unused-ignore`.
/// This should be run after all normal rules have been finished because this
/// works for diagnostics reported by other rules.
Lint rule implementation for `ban-unused-ignore`.
This should be run after all normal rules have been finished because this
works for diagnostics reported by other rules.
Lint rule implementation for ` ban - unused - ignore ` . This should be run after all normal rules have been finished because this works for diagnostics reported by other rules .
pub(crate) fn ban_unused_ignore(
    &self,
    specified_rules: &[Box<dyn LintRule>],
  ) -> Vec<LintDiagnostic> {
    const CODE: &str = "ban-unused-ignore";
    // If there's a file-level ignore directive containing `ban-unused-ignore`,
    // exit without running this rule.
    if self
      .file_ignore_directive
      .as_ref()
      .map_or(false, |file_ignore| file_ignore.has_code(CODE))
    {
      return vec![];
    }
    let executed_builtin_codes: HashSet<&'static str> =
      specified_rules.iter().map(|r| r.code()).collect();
    let is_unused_code = |&(code, status): &(&String, &CodeStatus)| {
      let is_unknown = !executed_builtin_codes.contains(code.as_str())
        && !self.plugin_codes.contains(code.as_str());
      !status.used && !is_unknown
    };
    let mut diagnostics = Vec::new();
    if let Some(file_ignore) = self.file_ignore_directive.as_ref() {
      for (unused_code, _status) in
        file_ignore.codes().iter().filter(is_unused_code)
      {
        let d = self.create_diagnostic(
          file_ignore.span(),
          CODE,
          format!("Ignore for code \"{}\" was not used.", unused_code),
          None,
        );
        diagnostics.push(d);
      }
    }
    for line_ignore in self.line_ignore_directives.values() {
      // We do nothing special even if the line-level ignore directive contains
      // `ban-unused-ignore`. `ban-unused-ignore` can be ignored only via the
      // file-level directive.
      for (unused_code, _status) in
        line_ignore.codes().iter().filter(is_unused_code)
      {
        let d = self.create_diagnostic(
          line_ignore.span(),
          CODE,
          format!("Ignore for code \"{}\" was not used.", unused_code),
          None,
        );
        diagnostics.push(d);
      }
    }
    diagnostics
  }
pub ( crate ) fn ban_unused_ignore ( & self , specified_rules : & [ Box < dyn LintRule > ] , ) -> Vec < LintDiagnostic > { const CODE : & str = " " ; // If there's a file-level ignore directive containing `ban-unused-ignore`, // exit without running this rule. if self . file_ignore_directive . as_ref ( ) . map_or ( false , | file_ignore | file_ignore . has_code ( CODE ) ) { return vec ! [ ] ; } let executed_builtin_codes : HashSet < & ' static str > = specified_rules . iter ( ) . map ( | r | r . code ( ) ) . collect ( ) ; let is_unused_code = | & ( code , status ) : & ( & String , & CodeStatus ) | { let is_unknown = ! executed_builtin_codes . contains ( code . as_str ( ) ) && ! self . plugin_codes . contains ( code . as_str ( ) ) ; ! status . used && ! is_unknown } ; let mut diagnostics = Vec :: new ( ) ; if let Some ( file_ignore ) = self . file_ignore_directive . as_ref ( ) { for ( unused_code , _status ) in file_ignore . codes ( ) . iter ( ) . filter ( is_unused_code ) { let d = self . create_diagnostic ( file_ignore . span ( ) , CODE , format ! ( " \" \" " unused_code ) , None , ) ; diagnostics . push ( d ) ; } } for line_ignore in self . line_ignore_directives . values ( ) { // We do nothing special even if the line-level ignore directive contains // `ban-unused-ignore`. `ban-unused-ignore` can be ignored only via the // file-level directive. for ( unused_code , _status ) in line_ignore . codes ( ) . iter ( ) . filter ( is_unused_code ) { let d = self . create_diagnostic ( line_ignore . span ( ) , CODE , format ! ( " \" \" " unused_code ) , None , ) ; diagnostics . push ( d ) ; } } diagnostics }
Lint rule implementation for `ban-unused-ignore`.
Lint rule implementation for ` ban - unused - ignore ` .
&self
specified_rules
&[Box<dyn LintRule>]