Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance linter diagnostic description #291

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/analyzer-config.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Configuration

The following configurations can be set in a `.editorconfig` file to configure preferences for analyzers.
The following configurations can be set in a `.editorconfig` file to configure preferences for analyzers. Note, that **all** configurations are set to false by default, so you have to turn them on individually according to the below table.

| Property | Possible values | Default value |
| Property | Possible values | Description |
| --- | --- | --- |
| `natls.style.comparisons` | `sign` (`<`, `=`, etc.), `short` (`LT`, `EQ`, etc.) | `sign` |
| `natls.style.qualifyvars` | `true`, `false` | `false` |
| `natls.style.disallowtoplevelvars` | `true`, `false` | `false` |
| `natls.style.comparisons` | `sign`, `short`, `false` | [`NL006`](..\tools/ruletranslator/src/main/resources/rules/NL006)|
| `natls.style.disallowtoplevelvars` | `true`, `false` | [`NL018`](..\tools/ruletranslator/src/main/resources/rules/NL018)|
| `natls.style.qualifyvars` | `true`, `false` | [`NL019`](..\tools/ruletranslator/src/main/resources/rules/NL019)|


# Example
Expand Down
17 changes: 14 additions & 3 deletions tools/ruletranslator/src/main/resources/rules/NL006
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ priority: MINOR
tags: convention
type: CODE_SMELL
description:
Operators can be specified multiple ways.
Operators can be specified multiple ways. Having consistent code guidelines for those cases is a good idea.

Having consistent code guidelines for those cases is a good idea.
This behavior can be configured using the ``natls.style.comparisons`` option in the [analyzer configuration](/docs/analyzer-config.md)

Use the following table to decide which operator to use:
Use the following table to decide which operator to use with the preferred operator configuration set as ``signs``

| Discouraged operator | Preferred operator |
| --- | --- |
Expand All @@ -17,3 +17,14 @@ Use the following table to decide which operator to use:
| ``NE`` | `<>`` |
| ``GE`` | `>=`` |
| ``LE`` | `<=`` |

For preferred operator configuration set as ``short``, the table look like this:

| Discouraged operator | Preferred operator |
| --- | --- |
| `>`` | ``GT`` |
| `<`` | ``LT`` |
| `=`` | ``EQ`` |
| `<>`` | ``NE`` |
| `>=`` | ``GE`` |
| `<=`` | ``LE`` |
12 changes: 7 additions & 5 deletions tools/ruletranslator/src/main/resources/rules/NL018
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ type: CODE_SMELL
description:
Typed variables should always be qualified with their (top) group name to improve readability.

Consider this DEFINE DATA structure:
DEFINE DATA
Consider this ``DEFINE DATA`` structure:
``DEFINE DATA
LOCAL
1 #WORK
2 #MYVAR (N1)
END-DEFINE
END-DEFINE``

Now, this is the correct way to write a MOVE statement:
Now, this is the correct way to write a ``MOVE`` statement:

MOVE 1 TO #WORK.#MYVAR (as opposed to MOVE 1 TO #MYVAR)
``MOVE 1 TO #WORK.#MYVAR`` (as opposed to ``MOVE 1 TO #MYVAR``)

This behavior can be configured using the ``natls.style.disallowtoplevelvars`` option in the [analyzer configuration](/docs/analyzer-config.md)
10 changes: 6 additions & 4 deletions tools/ruletranslator/src/main/resources/rules/NL019
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ type: CODE_SMELL
description:
A typed variable should always have a group parent, so that it can be qualified.

Consider this DEFINE DATA structure:
DEFINE DATA
Consider this ``DEFINE DATA`` structure:
``DEFINE DATA
LOCAL
1 #MYVAR1 (N1)
1 #WORK
2 #MYVAR2 (N1)
END-DEFINE
END-DEFINE``

#MYVAR1 is incorrectly defined on level 1, whereas #MYVAR2 is defined correctly with a group parent.
``#MYVAR1`` is incorrectly defined on level 1, whereas ``#MYVAR2`` is defined correctly with a group parent.

This behavior can be configured using the ``natls.style.qualifyvars`` option in the [analyzer configuration](/docs/analyzer-config.md)