<commit_before>---
layout: default
title: CodeNarc - Developer Guide
---  

# CodeNarc - Developer Guide

**Contents**
  * [The codenarc Command-line Script](#the-codenarc-command-line-script)
  * [New Rule Checklist](#new-rule-checklist)
  * [Before You Submit a Patch or Check-In Code](#before-you-submit-a-patch-or-check-in-code)
  * [Intellij IDEA Support](#intellij-idea-support)


## The codenarc Command-line Script

There is a `codenarc.groovy` command-line script in the root directory of the project.
It is intended to streamline common development tasks. Currently, it supports a
`create-rule` task for creating new **CodeNarc** rules.

### codenarc create-rule

The `create-rule` task performs the following steps:
  * Prompt for the rule name
  * Prompt for the existing ruleset (category) name to which the rule is added
  * Create a new rule class file in the proper package (under src/main/groovy)
  * Create a new rule test class file (under src/test/groovy)
  * Add placeholder description messages for the new rule to "codenarc-base-messages.properties"
  * Add the new rule to the chosen ruleset XML file

**RUNNING**

On **Unix/Mac**, you can run the following from the project root directory:

    ./codenarc create-rule

On **Windows**, you can run:

    codenarc create-rule

(If **Windows** is not configured to automatically run *.groovy files,
just can run `groovy codenarc create-rule`)

**AFTER YOU RUN** `codenarc create-rule`

After you run `codenarc create-rule`, finish up the rule implementation, including the following:
  1. Edit the generated rule class and associated test class to add the proper implementation.<commit_msg>Convert site to markdown<commit_after>---
layout: default
title: CodeNarc - Developer Guide
---  

# CodeNarc - Developer Guide

**Contents**
  * [The codenarc Command-line Script](#the-codenarc-command-line-script)
  * [New Rule Checklist](#new-rule-checklist)
  * [Before You Submit a Pull Request or Patch](#before-you-submit-a-pull-request-or-patch)
  * [Intellij IDEA Support](#intellij-idea-support)


## The codenarc Command-line Script

There is a `codenarc.groovy` command-line script in the root directory of the project.
It is intended to streamline common development tasks. Currently, it supports a
`create-rule` task for creating new **CodeNarc** rules.

### codenarc create-rule

The `create-rule` task performs the following steps:
  * Prompt for the rule name
  * Prompt for the existing ruleset (category) name to which the rule is added
  * Create a new rule class file in the proper package (under src/main/groovy)
  * Create a new rule test class file (under src/test/groovy)
  * Add placeholder description messages for the new rule to "codenarc-base-messages.properties"
  * Add the new rule to the chosen ruleset XML file

**RUNNING**

On **Unix/Mac**, you can run the following from the project root directory:

      ./codenarc create-rule

On **Windows**, you can run:

      codenarc create-rule

(If **Windows** is not configured to automatically run *.groovy files,
just can run `groovy codenarc create-rule`)

**AFTER YOU RUN** `codenarc create-rule`

After you run `codenarc create-rule`, finish up the rule implementation, including the following:
  1. Edit the generated rule class and associated test class to add the proper implementation.
{'fraction_non_alphanumeric': 0.09229847168115074, 'fraction_numerical': 0.0005993407252022775, 'mean_word_length': 4.183229813664596, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2992231', 'n_tokens_mistral': 986, 'n_tokens_neox': 951, 'n_words': 410}