<commit_before># TFLint Developer Guide

The goal of this guide is to quickly understand how TFLint works and to help more developers contribute.

## Core Concept

TFLint is just a thin wrapper of Terraform. Configuration loading and expression evaluation etc. depend on Terraform's internal API, and it only provides an interface to do them as linter.

There are three important packages to understand its behavior:

- `tflint`
  - This package is the core of TFLint as a wrapper for Terraform. It allows accesses to `terraform/configs.Config` and `terraform/terraform.BuiltinEvalContext` and so on.
- `rules`
  - This package is a provider of all rules.
- `cmd`
  - This package is the entrypoint of the app.

## How does it work

These processes are described in [`cmd/cli.go`](https://github.com/terraform-linters/tflint/blob/master/cmd/cli.go).

### 1. Loading configurations

All Terraform's configuration files are represented as `configs.Config`. [`tflint/tflint.Loader`](https://github.com/terraform-linters/tflint/blob/master/tflint/loader.go) uses the `(*configs.Parser) LoadConfigDir` and `configs.BuildConfig` to access to `configs.Config` in the same way as Terraform.

Similarly, prepare `terraform.InputValues` using `(*configs.Parser) LoadValuesFile`.

### 2. Setting up a new Runner

A [`tflint/tflint.Runner`](https://github.com/terraform-linters/tflint/blob/master/tflint/runner.go) is initialized for each `configs.Config`. These have their own evaluation context for that module, represented as `terraform.BuiltinEvalContext`.

it uses `(*terraform.BuiltinEvalContext) EvaluateExpr` to evaluate expressions. Unlike Terraform, it provides a mechanism to determine if an expression can be evaluated.

### 3. Inspecting configurations

It inspects `configs.Config` via `tflint.Runner`. All rules implement the `Check` method that takes `tflint.Runner` as an argument, and emits an issue if needed.

## Building

You need Go 1.14 or later to build.

```console
$ make tools
$ make build
```

## Adding a new rule

You can use the rule generator to add new rules (Currently, this generator supports only AWS rules).<commit_msg>Tweaks DEVELOPING.md for Go 1.15<commit_after># TFLint Developer Guide

The goal of this guide is to quickly understand how TFLint works and to help more developers contribute.

## Core Concept

TFLint is just a thin wrapper of Terraform. Configuration loading and expression evaluation etc. depend on Terraform's internal API, and it only provides an interface to do them as linter.

There are three important packages to understand its behavior:

- `tflint`
  - This package is the core of TFLint as a wrapper for Terraform. It allows accesses to `terraform/configs.Config` and `terraform/terraform.BuiltinEvalContext` and so on.
- `rules`
  - This package is a provider of all rules.
- `cmd`
  - This package is the entrypoint of the app.

## How does it work

These processes are described in [`cmd/cli.go`](https://github.com/terraform-linters/tflint/blob/master/cmd/cli.go).

### 1. Loading configurations

All Terraform's configuration files are represented as `configs.Config`. [`tflint/tflint.Loader`](https://github.com/terraform-linters/tflint/blob/master/tflint/loader.go) uses the `(*configs.Parser) LoadConfigDir` and `configs.BuildConfig` to access to `configs.Config` in the same way as Terraform.

Similarly, prepare `terraform.InputValues` using `(*configs.Parser) LoadValuesFile`.

### 2. Setting up a new Runner

A [`tflint/tflint.Runner`](https://github.com/terraform-linters/tflint/blob/master/tflint/runner.go) is initialized for each `configs.Config`. These have their own evaluation context for that module, represented as `terraform.BuiltinEvalContext`.

it uses `(*terraform.BuiltinEvalContext) EvaluateExpr` to evaluate expressions. Unlike Terraform, it provides a mechanism to determine if an expression can be evaluated.

### 3. Inspecting configurations

It inspects `configs.Config` via `tflint.Runner`. All rules implement the `Check` method that takes `tflint.Runner` as an argument, and emits an issue if needed.

## Building

You need Go 1.15 or later to build.

```console
$ make tools
$ make build
```

## Adding a new rule

You can use the rule generator to add new rules (Currently, this generator supports only AWS rules).
{'fraction_non_alphanumeric': 0.08915718597631762, 'fraction_numerical': 0.003482702577199907, 'mean_word_length': 4.6020806241872565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2712048', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1251, 'n_words': 513}