lint/lib/functions
Stepan Koltsov e059100991
Ignore files marked with @generated marker (#1689)
* Ignore files marked with @generated marker

`@generated` marker is used by certain tools to understand that the
file is generated, so it should be treated differently than a file
written by a human:
* these files do not need to be reformatted,
* diffs in these files are less important,
* and linters should not be invoked on these files.

This PR proposes builtin support for `@generated` marker (and
`@not-generated` marker to mark file as not generated when it
contains `@generated` marker, like `README.md`).

I have not found a standard for a generated file marker, but:
* Facebook [uses `@generated` marker](https://tinyurl.com/fb-generated)
* Phabricator tool which was spawned from Facebook internal tool
  [also understands `@generated` marker](https://git.io/JnVHa)
* Cargo inserts `@generated` marker into [generated Cargo.lock files](https://git.io/JnVHP)

Super-linter supports regex includes and excludes, but they are
harder to maintain (each repository needs to be configured) than
patching the tools which generate the files.

My personal story is that I maintain rust-protobuf crate, which
started emitting `@generated` markers [six years ago](https://git.io/JnV5h)
after a request of a Phabricator user.

Test Plan:

Create a test file `test.sh`:

```
echo $a
```

Run:

```
docker run -e RUN_LOCAL=true -v $HOME/tmp/g:/tmp/lint super-linter-test
```

Result is:

```
In /tmp/lint/test.sh line 1:
echo $a
^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
     ^-- SC2154: a is referenced but not assigned.
     ^-- SC2086: Double quote to prevent globbing and word splitting.
...
2021-06-22 23:46:16 [ERROR]   ERRORS FOUND in BASH:[1]
```

Now add `@generated` to the file and run again:

```
2021-06-22 23:47:13 [NOTICE]   All file(s) linted successfully with no errors detected
```

Additionally, add `@not-generated` in addition to `@generated`, and
linter error pops up again.

* cleanup

* remove space

* fix non utf return

* fix non utf return

Co-authored-by: Lukas Gravley <admiralawkbar@github.com>
2021-06-28 07:59:11 -05:00
..
buildFileList.sh Ignore files marked with @generated marker (#1689) 2021-06-28 07:59:11 -05:00
detectFiles.sh Ignore files marked with @generated marker (#1689) 2021-06-28 07:59:11 -05:00
linterRules.sh LINTER_RULE_PATH fix (#1649) 2021-06-10 13:09:24 -05:00
linterVersions.sh Implement a test suite with InSpec (#1466) 2021-04-30 11:29:15 -05:00
log.sh adding fixes (#1516) 2021-05-04 11:33:21 -05:00
possum.sh break out: (#990) 2020-11-12 11:27:34 -06:00
updateSSL.sh Certs (#1470) 2021-04-26 09:00:42 -05:00
validation.sh Ignore files that are ignored by Git (#1185) 2021-02-18 12:15:50 -06:00
worker.sh remove tap and tests (#1496) 2021-04-30 12:46:24 -05:00