AtomLinter / linter-clang

Lint C-based files using Clang.
55 stars 29 forks source link

Linter-Clang 'Fix' Recommendations Applying Faulty Corrections #240

Open HipplerJ opened 6 years ago

HipplerJ commented 6 years ago

Description

First, I apologize if I've submitted this bug report to the wrong issue queue. I'm not entirely sure if the issue resides with Atom of the Linter/Linter-clang package.

I've noticed in some instances when linter recognizes a compilation error or warning and offers a Fix/Resolution, it will often append the correction to the wrong location in the document, sometimes on an entirely different line than where the error exists. In addition, when this error happens, I’d also lose the ability to navigate through the document using the arrow keys until I clicked somewhere on the screen with the mouse and reset the cursor.

In the image below, I declared a function that receives an integer pointer, but intentionally neglected to pass it the integer variable 'accepted' by reference. Linter recognized the error, noted its location and details, and recommended a solution. When I select the option 'Fix' to implement linter's solution, it added the required ampersand (&) in the line above at an incorrect index.

This does not happen every time the linter fix option is implemented (issue is intermittent), but it does happen pretty frequently.

screen shot 2018-06-06 at 2 04 01 pm

Steps to Reproduce

  1. Download Linter/Linter-clang packages
  2. Create a C/C++ compilation error/warning like a missing semicolon or passing a variable by reference without the necessary ampersand.
  3. Use Linter's 'Fix Solution'
  4. See if solution was implemented to the correct or incorrect location

Expected behavior: In my instance in the image above, linter should have added the ampersand before the 'accepted' variable being passed to the introduction function

Actual behavior: Linter adds the ampersand to the line above (almost randomly) right in the middle of my socket variable "establishedConnectionFD"

Reproduces how often: 15% -20% Occurrence. Relatively intermittent but it does happen enough (and on different systems) to likely be a problem.

Versions

Operating System: macOS High Sierra Version 10.13.4

$ atom --version Atom : 1.27.2 Electron: 1.7.15 Chrome : 58.0.3029.110 Node : 7.9.0

$ apm --version apm 1.19.0 npm 3.10.10 node 6.9.5 x64 atom 1.27.2 python 2.7.10 git 2.10.1

$ apm list --installed --bare atom-material-ui@2.1.3 atom-sublime-monokai-syntax@0.4.4 autocomplete-ctags@0.4.1 batman-syntax@1.1.0 busy-signal@1.4.3 file-icons@2.1.21 highlight-selected@0.13.1 intentions@1.1.5 linter@2.2.0 linter-clang@4.1.2 linter-ui-default@1.7.1 monokai@0.24.0 script@3.18.1