ameba icon indicating copy to clipboard operation
ameba copied to clipboard

Path for source files in config file should preserve relative position

Open veelenga opened this issue 5 years ago • 0 comments

cc @petr-fischer

Reproduction:

$ cat ameba/.ameba.yml                                                                                                                                                                                       
# This configuration file was generated by `ameba --gen-config`
# on 2021-04-21 10:00:29 UTC using Ameba version 0.14.3.
# The point is for the user to remove these configuration records
# one by one as the reported problems are removed from the code base.

# Problems found: 1
# Run `ameba --only Lint/UselessAssign` for details
Lint/UselessAssign:
  Description: Disallows useless variable assignments
  Excluded:
  - src/ameba/config.cr
  Enabled: true
  Severity: Warning

Correct

$ cd ameba
$ ameba /Users/me/Dev/repos/ameba/src/ameba/config.cr --format json --config /Users/me/Dev/repos/ameba/.ameba.yml

# no errors

Incorrect

$ cd ../
$ ameba /Users/me/Dev/repos/ameba/src/ameba/config.cr --format json --config /Users/me/Dev/repos/ameba/.ameba.yml

{"sources":[{"path":"/Users/me/Dev/repos/ameba/src/ameba/config.cr","issues":[{"rule_name":"Lint/UselessAssign","severity":"Warning","message":"Useless assignment to variable `test`","location":{"line":124,"column":5},"end_location":{"line":124,"column":8}}]}],"metadata":{"ameba_version":"0.14.3","crystal_version":"1.0.0"},"summary":{"target_sources_count":1,"issues_count":1}}% 

The path is inappropriately matched in

https://github.com/crystal-ameba/ameba/blob/df14fda0d850edde9bc8f2d86814d6e742bab204/src/ameba/rule/base.cr#L90-L95

veelenga avatar Apr 21 '21 11:04 veelenga