gnolang / tlin

Advanced Linter for Gno
MIT License
13 stars 1 forks source link

Displaying More Context in Lint Results #60

Open notJoon opened 1 month ago

notJoon commented 1 month ago

Currently, when linting is executed, the results only show the problematic line or area. The issue is that when only the line is displayed, it is difficult to convey to the user what exactly wrong, as the surrounging context is excluded.

Therefore, it would be nice to formatting the problematic line along with its surrounding context to clarify the issue more precisely.

Example

Current

error: return-in-defer
 --> defer2.gno
  |
6 |                return
  |                 ~~~~~~~
  | Avoid using return statement inside a defer function

Updated


error: return-in-defer
 --> defer2.gno
  |
4 |             defer func() {            // <- prior context
5 |                ...                    // <- omit the unrelated part
6 |                return                 // <- main problematic line
  |                ~~~~~~~
  | Avoid using return statement inside a defer function