Skip to content

Commit

Permalink
Add results to the run summary, new multiline comments option (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkelM authored Feb 10, 2024
1 parent c27d4b4 commit ea889ed
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 92 deletions.
14 changes: 10 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
dockerfile
CHANGELOG.md
README.md
.github/
development/
validation/
.dockerignore
.gitattributes
.gitignore
.gitignore
.rubocop.yml
CHANGELOG.md
dockerfile
LICENSE
PRIVACY.md
README.md
development/
9 changes: 6 additions & 3 deletions .github/config.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
todo-pr-checker:
# When should comments be posted?
post_comment: 'items_found'
# What action items should be looked for (will overwrite default values)
# If multiline comments should also be searched for action items
# This may result in some false positives or negatives if the opening or closing lines of a comment are not in the diff
enable_multiline_comments: false
# What action items should be looked for (setting this will the overwrite default values)
action_items: ['TODO', 'FIXME', 'BUG']
# Languages/file types to add. At least either the line comment or both block comment definitions are required.
# If there are no line comments in the language, set the value to null.
# If there are no line comments in the language, you may set the value to null.
add_languages: [
['js', '//', '/*', '*,'],
['js', '//', '/*', '*/'],
['css', null, '/*', '*/'],
['.py', '#']
]
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Layout/EndOfLine:
Enabled: false

Metrics/MethodLength:
Max: 40
Max: 50

Metrics/BlockLength:
Enabled: false
Expand Down
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# Changelog

## v1.2.0
## v1.3.0

<!--Releasenotes start-->
- The app will now always include the results of the action item search in the check run summary.
- Added an option to enable multiline block comments. This option is disabled by default, as it may cause the app to incorrectly identify action items.
- If the app encounters an error while the check is running, the check will now be concluded as neutral and the error message will be included in the check run summary.
- Fixed a bug where setting one of the values of the `add_languages` option to `null` would cause the app to not accept any new languages.
- Fixed a bug where the app would incorrectly classify a line as not being part of a block comment.
<!--Releasenotes end-->

## v1.2.0

- Block comments that end one the same line they start on are now correctly identified as such.
- Improved the performance of the app by optimizing the way it looks for action items in the code.
- The app now supports setting options for the app in a `.github/config.yml` file.
- Added an option to control when the app should post a comment.
- Added an option to control which action items the app should look for.
- Added an option to add support for additional languages/file types.
- Added an option to control whether the app should look for action items in a case-sensitive manner.
<!--Releasenotes end-->

## v1.1.3

Expand Down
21 changes: 7 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
<i>Get the app on the <a href="https://github.com/marketplace/todo-pr-checker">GitHub Marketplace</a></i>
</p>



Do you keep forgetting to resolve that one `// TODO:...` or fix the last ` # Bug...` before merging your Pull Requests?

The Todo PR Checker will make sure that doesn't happen anymore.
Expand All @@ -20,7 +18,7 @@ This list will update whenever new changes are pushed, so you always know exactl
The app supports a wide array of programming languages and action items.
Should you find that your language of choice or action item is not supported out-of-the-box, you can easily configure the app to support it.

To minimize falsely identified comments (e.g. the characters that start a comment are contained in a string), the app will only detect action items if the comment starts in its own line.
To minimize falsely identified comments (e.g. the characters that start a comment are contained in a string), the app will only look for action items if the comment starts in its own line.
The following examples would *not* cause the app to flag the action items:

```javascript
Expand All @@ -31,15 +29,8 @@ If the comment does not start on its own line, the TODO action item will not be
*/
```

These action items would however be flagged correctly:

```javascript
// TODO: If a line comment stands on its own, action items will be flagged.
/*
Multiline block comments are supported, no matter how many lines they span,
the TODO will be detected
*/
```
Additionally, support for multiline comments is *disabled* by default, as it may cause the app to incorrectly identify action items if the opening or closing characters of the block comment are not included in the Pull Request diff.
You may enable support for multiline comments in the options, see the section below.

## Options

Expand All @@ -50,7 +41,8 @@ To configure options, add a `todo-pr-checker` key at the top-level of your `.git

```yaml
todo-pr-checker:
post_comment: true
post_comment: 'items_found'
(...)
```

To get started, you can copy the `.github/config.yml` file from this repository and adjust it to your needs.
Expand All @@ -60,9 +52,10 @@ To get started, you can copy the `.github/config.yml` file from this repository
| Option | Possible Values | Description | Default |
| --- | --- | --- | --- |
| `post_comment` | `items_found`, `always`, `never` | Controls when the app should post a comment. By default, a comment is only posted if an action item has been found. If set to `never`, the check will still fail. If set to `always`, the app will post a comment that all action items have been resolved if none are found. | `items_found` |
| `enable_multiline_comments` | `true`, `false` | Whether or not looking for action items in multiline block comments is enabled or not. When enabled, the app *may* incorrectly mark action items in your Pull Request if at least one of the opening or closing line of the block comment (e.g. `*/` and `/*` in JavaScript) are not included in the Pull Request diff, which causes them to not be found by the app. For multiline comments to always work, you must ensure that both the opening and closing characters are included in the diff. Action items located on the first line of a block comment will always be detected, even if this option is disabled. | `false` |
| `action_items` | `string[]` | A list of action items to look for in code comments. If you set this option, the default values will be overwritten, so you must include them in your list to use them. | `['TODO', 'FIXME', 'BUG']` |
| `case_sensitive` | `true`, `false` | Controls whether the app should look for action items in a case-sensitive manner. | `false` |
| `add_languages` | `[string[file_type, line_comment, block_comment_start, block_comment_end]]`</br>Example: `[['js', '//', '/*', '*,'], ['css', null, '/*', '*/'], ['.py', '#']]` | A list of a list of programming languages to add support for. This list will be added to the already supported languages. If you define a language that is already supported, the default values will be overwritten. `file_type` must be the extension of the file (e.g. `js`) and may start with a `.`. You may omit the block comment definitions if the file type does not support block comments. If you want to omit the definition of a `line_comment`, you must set `line_comment` to `null`. If defining `block_comment_start`, `block_comment_end` must also be defined. *The file types shown in the example are already natively supported by the app.* | `null` |
| `add_languages` | `[string[file_type, line_start, block_start, block_end]]`</br>Example: `[['js', '//', '/*', '*,'], ['css', null, '/*', '*/'], ['.py', '#']]` | A list of a list of programming languages to add support for. This list will be added to the already supported languages. If you define a language that is already supported, the default values will be overwritten. `file_type` must be the extension of the file (e.g. `js`) and may start with a `.`. You may omit the block comment definitions if the file type does not support block comments. If you want to omit the definition of a line comment, you must set `line_start` to `null`. If defining `block_start`, `block_end` must also be defined. *The file types shown in the example are already natively supported by the app.* | `null` |

<details>
<summary>Expand me to see the currently supported file types:</summary>
Expand Down
Loading

0 comments on commit ea889ed

Please sign in to comment.