preslavmihaylov / todocheck

A static code analyser for annotated TODO comments
MIT License
422 stars 42 forks source link

[WIP] Fix JSON output for closed-issue type comments not including TODO message #169

Closed bengsparks closed 2 years ago

bengsparks commented 2 years ago

Reopened the PR due to duplicate commits in the old PR.

The output for single line comments currently looks good:

{
  "type": "Issue doesn't exist",
  "filename": "testing/scenarios/custom_todos/groovy/main.groovy",
  "line": 21,
  "message": "// TODO 3: The issue is non-existent",
  "metadata": {
    "issueID": "3"
  }
},

but the output for multiline looks a little odd.

{
  "type": "Issue doesn't exist",
  "filename": "testing/scenarios/custom_todos/groovy/main.groovy",
  "line": 56,
  "message": "/**\u0000* TODO 2: Invalid todo as issue is closed\u0000*/",
  "metadata": {
    "issueID": "2"
  }
},
preslavmihaylov commented 2 years ago

I'm not sure what's the issue you mentioned in the description but currently, this is not working as expected.

for multiline malformed comments, the output is:

  {
    "type": "Malformed todo",
    "filename": "main.go",
    "line": 15,
    "message": "TODO should match pattern - TODO {task_id}:",
    "metadata": {}
  }

but the message should be the actual TODO comment.

Also, please make sure tests pass on CI. Adding WIP for now until the issues are resolved. Feel free to remove the tag once ready

preslavmihaylov commented 2 years ago

Hey @bengsparks any updates on this PR? Could be a good opportunity for participating in hacktoberfest :)

bengsparks commented 2 years ago

Hi @preslavmihaylov, sorry for the lack of progress. When I last reviewed this PR, I was a little confused; perhaps I misunderstood the task.

It would be best if we were to discuss input and expected output; the task will be clear enough thereafter for me to complete this PR :)

preslavmihaylov commented 2 years ago

Hi @bengsparks,

essentially, the expected output is to get the TODO comment visible in the message field. Currently, this is not the case for malformed TODO error types which instead of showing the TODO comment shows the error message.

This is how the app currently behaves for malformed TODOs:

  {
    "type": "Malformed todo",
    "filename": "main.go",
    "line": 15,
    "message": "TODO should match pattern - TODO {task_id}:",
    "metadata": {}
  }

But instead, it should be e.g.:

  {
    "type": "Malformed todo",
    "filename": "main.go",
    "line": 15,
    "message": "// TODO: Fix this",
    "metadata": {}
  }

Is it clear now?

bengsparks commented 2 years ago

Sorry, I have currently run out of available time for this project :/ Someone else is free to take up this PR