<commit_before>#include "mo/rule/UnusedFormalParameterRule.h"
#include "mo/ruleset/RuleSet.h"
#include "mo/RuleData.h"
#include "mo/RuleViolation.h"
#include "mo/util/CursorUtil.h"

#include <clang/AST/Decl.h>
#include <clang/AST/DeclObjC.h>

using namespace clang;

RuleSet UnusedFormalParameterRule::rules(new UnusedFormalParameterRule());

void UnusedFormalParameterRule::apply(CXCursor& node, CXCursor& parentNode, RuleData& data) {
  Decl *decl = CursorUtil::getDecl(node);
  if (decl) {
    ParmVarDecl *parameterDecl = dyn_cast<ParmVarDecl>(decl);
    if (parameterDecl) {
      if (!parameterDecl->isUsed()) {
        RuleViolation violation(node, this);
        data.addViolation(violation);
      }
    }
  }
}

const string UnusedFormalParameterRule::name() const {
  return "unused formal parameter";
}<commit_msg>ignore method decleration within ObjCInterfaceDecl<commit_after>#include "mo/rule/UnusedFormalParameterRule.h"
#include "mo/ruleset/RuleSet.h"
#include "mo/RuleData.h"
#include "mo/RuleViolation.h"
#include "mo/util/CursorUtil.h"

#include <clang/AST/Decl.h>
#include <clang/AST/DeclObjC.h>

using namespace clang;

RuleSet UnusedFormalParameterRule::rules(new UnusedFormalParameterRule());

#include <iostream>
using namespace std;

void UnusedFormalParameterRule::apply(CXCursor& node, CXCursor& parentNode, RuleData& data) {
  Decl *decl = CursorUtil::getDecl(node);
  if (decl) {
    ParmVarDecl *parameterDecl = dyn_cast<ParmVarDecl>(decl);
    if (parameterDecl) {
      if (!parameterDecl->isUsed()) {
        DeclContext *context = parameterDecl->getDeclContext();
        do {
          if (isa<ObjCInterfaceDecl>(context)) {
            return;
          }
          context = context->getParent();
        } while (context);
        RuleViolation violation(node, this);
        data.addViolation(violation);
      }
    }
  }
}

const string UnusedFormalParameterRule::name() const {
  return "unused formal parameter";
}
{'fraction_non_alphanumeric': 0.12819203268641471, 'fraction_numerical': 0.0, 'mean_word_length': 4.323369565217392, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3129932', 'n_tokens_mistral': 643, 'n_tokens_neox': 644, 'n_words': 122}