Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Code not showing in generated report #119

Open
PeppeL-G opened this issue Nov 12, 2021 · 3 comments
Open

[bug] Code not showing in generated report #119

PeppeL-G opened this issue Nov 12, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@PeppeL-G
Copy link

🐞 Bug report

Description

I've reviewed the code and written some comments that are stored in the CSV file, e.g.:

sha,filename,url,lines,title,comment,priority,category,additional,id,private
"","\JUWeb\package.json","","13:0-19:23","","All of these weren't mentioned in the report.","0","","","627e63ff-447b-459f-8213-e9f73f81c908","0"
"","\JUWeb\views\layouts\main.hbs","","6:0-11:7","","Removecode you don't use; submit production ready code.","0","","","2c47b831-34a8-46cc-9c09-8eabd2dfcad7","0"
"","\JUWeb\views\layouts\main.hbs","","63:0-76:17","","Remove...","0","","","76a1c8b5-96ba-4777-ad5e-fc5b87bcb231","0"
"","\JUWeb\views\about.hbs","","3:0-4:0","","Write CSS code in CSS files.","0","","","0c9b2c10-9f20-49b3-8a0c-16ca66613e33","0"
"","\JUWeb\views\about.hbs","","16:0-16:7","","What semantic meaning does this have?","0","","","b1cf3c83-1ba8-4bc8-a794-5eed86e70fb2","0"
"","\JUWeb\views\about.hbs","","40:0-41:0","","CSS in CSS files...","0","","","95750e49-0a9f-4d47-9d77-87073425aa23","0"
"","\JUWeb\views\about.hbs","","42:0-42:44","","Avoid using BR. Use CSS margins.","0","","","7cc59d43-c1f9-438c-b840-6e76de546674","0"
"","\JUWeb\views\show-all-humans.hbs","","1:0-11:0","","? What do you use this for?","0","","","34511a4c-a4f8-41aa-97d5-26b612112e97","0"
"","\JUWeb\views\start.hbs","","5:0-5:215","","This HTML code is not vlaid.","0","","","0d012f8e-553f-44ac-a43a-84c0295a089f","0"
"","\JUWeb\views\review\delete_review.hbs","","3:0-5:7","","you have no protection against CSRF attacks.","0","","","4340a661-438e-45b8-9a5b-29b0c223c732","0"
"","\JUWeb\app.js","","17:0-18:0","","Remoce code you don't use...","0","","","b77e1e4f-3376-4470-b773-30314aab2c68","0"
"","\JUWeb\app.js","","23:0-26:27","","Alkways use const/var/let.","0","","","b71ea3cb-1459-4b02-b587-d05c3821e642","0"
"","\JUWeb\app.js","","20:0-22:25","","? I don't understand this. Potential security vulnerbaility.","0","","","d2bf0dea-087d-4488-a95f-1e9d84248771","0"
"","\JUWeb\app.js","","56:0-60:2","","...","0","","","62b84db8-7813-49ee-8ab8-00be5250df9c","0"
"","\JUWeb\static\css\layout.css","","37:0-42:6","","I don't understand why there's only 4 blank lines here, and not 10.","0","","","7fb78395-0617-44b4-b225-352b802c7797","0"
"","\JUWeb\static\css\layout.css","","113:0-114:0","","Image.jpeg is no goos name on an image. The name should reflect what the image shows.","0","","","322550e3-dfa2-47fd-b3c9-cd125b0c6a52","0"
"","\JUWeb\database.js","","9:0-16:6","","Mixed indentaiton...","0","","","7ed19184-332c-4674-89a7-0c5d6fbef193","0"
"","\JUWeb\database.js","","23:0-38:1","","Mixed indentaiton...","0","","","627d8a6b-3336-4e02-a654-283784f0ab8d","0"
"","\JUWeb\database.js","","34:0-34:18","","dates shouldn't be stored as text.","0","","","9baabbfa-fa3c-4167-a9b7-ea45be842c8c","0"
"","\JUWeb\database.js","","55:0-56:0","","Remove code you don't use...","0","","","8573f718-848a-45ef-8ad3-44185e1ca49e","0"
"","\JUWeb\routers\blog-router.js","","25:0-28:2","","?","0","","","5e66211f-0646-4270-a8f3-baabdf01a237","0"
"","\JUWeb\routers\blog-router.js","","194:0-200:2","","Security vulnerability (no authorization).","0","","","50f51f7c-88cb-4835-90d4-5365c26cfe26","0"
"","\JUWeb\routers\blog-router.js","","149:0-154:10","","Hanlde errors.","0","","","a73b39d9-e922-468b-ab0c-b58afdac125f","0"
"","\JUWeb\routers\blog-router.js","","122:0-128:6","","Handle errors. Won't point out it more.","0","","","773b7c9e-0562-4526-a34d-173879f83199","0"
"","\JUWeb\routers\faq-router.js","","6:0-23:2","","Be consistent with your idnentaiton...","0","","","e8907737-2f45-4a49-9af1-7542a034c16d","0"
"","\JUWeb\routers\faq-router.js","","35:0-36:0","","Prefer const over let.","0","","","7a926e62-105c-49e4-bfd3-4096983936e5","0"
"","\JUWeb\routers\faq-router.js","","162:0-189:2","","Security vulernability. Also, you try to send back 2 responses, and that makes no sense and won't work.","0","","","8143e68a-1c31-4035-b038-490c73ba1f20","0"
"","\JUWeb\routers\review-router.js","","113:0-127:2","","Security vulnerbilaity...","0","","","3d3f8dae-7ad3-45a0-aae4-339b426faf2d","0"
"","\JUWeb\sqltest.sql","","13:0-13:11","","Hello","0","","","9aed7a9b-64f1-43d9-a756-f98d44f6cd5a","0"

Then I've created my own report template, with the body looking like this:

<body>
  <h1 class="main-headline">Code Review Results</h1>
  {{#each this as |item|}}
  <section class="file-section">
    <h2 class="file-section-headline">{{item.group}}</h2>
    {{#each item.lines as |line|}}
    <table class="review-table" style="margin-bottom: 1.5em;">
      {{#if line.comment}}
      <tr class="row-description">
        <td class="caption">Description</td>
        <td class="text">
          <p>{{line.comment}}</p>
        </td>
      </tr>
      {{/if}}
      <tr class="row-code">
        <td class="caption">Code</td>
        <td class="text">
          <pre><code id="code-block-{{@../index}}-{{@index}}">{{codeBlock line.code}}</code></pre>
        </td>
      </tr>
    </table>
    {{/each}}
  </section>
  {{/each}}
</body>

When I generate the report based on this template, the highlighted code for each comment is only shown for one of all my comments. For all other of my comments, the code is empty. Here's part of the body for the generated report:

    <table class="review-table" style="margin-bottom: 1.5em;">
      <tr class="row-description">
        <td class="caption">Description</td>
        <td class="text">
          <p>Avoid using BR. Use CSS margins.</p>
        </td>
      </tr>
      <tr class="row-code">
        <td class="caption">Code</td>
        <td class="text">
          <pre><code id="code-block-2-3"></code></pre>
        </td>
      </tr>
    </table>
  </section>
  <section class="file-section">
    <h2 class="file-section-headline">\JUWeb\views\show-all-humans.hbs</h2>
    <table class="review-table" style="margin-bottom: 1.5em;">
      <tr class="row-description">
        <td class="caption">Description</td>
        <td class="text">
          <p>? What do you use this for?</p>
        </td>
      </tr>
      <tr class="row-code">
        <td class="caption">Code</td>
        <td class="text">
          <pre><code id="code-block-3-0">&lt;h2&gt;All Humans&lt;/h2&gt;
{{#if humans.length}}
  &lt;ul&gt;
    {{#each humans}}
      &lt;li&gt;{{name}}&lt;/li&gt;
    {{/each}}
  &lt;/ul&gt;
{{else}}
  &lt;p&gt;No humans exist.&lt;/p&gt;
{{/if}}
</code></pre>
        </td>
      </tr>
    </table>
  </section>
  <section class="file-section">
    <h2 class="file-section-headline">\JUWeb\views\start.hbs</h2>
    <table class="review-table" style="margin-bottom: 1.5em;">
      <tr class="row-description">
        <td class="caption">Description</td>
        <td class="text">
          <p>This HTML code is not vlaid.</p>
        </td>
      </tr>
      <tr class="row-code">
        <td class="caption">Code</td>
        <td class="text">
          <pre><code id="code-block-4-0"></code></pre>
        </td>
      </tr>
    </table>
  </section>
  <section class="file-section">
    <h2 class="file-section-headline">\JUWeb\views\review\delete_review.hbs</h2>
    <table class="review-table" style="margin-bottom: 1.5em;">
      <tr class="row-description">
        <td class="caption">Description</td>
        <td class="text">
          <p>you have no protection against CSRF attacks.</p>
        </td>
      </tr>
      <tr class="row-code">
        <td class="caption">Code</td>
        <td class="text">
          <pre><code id="code-block-5-0"></code></pre>
        </td>
      </tr>
    </table>
  </section>

Why does the code only show for one of my comments? I need the code to be shown for all my comments. Is there a setting somewhere that I've missed, or is there a bug somewhere?

@PeppeL-G PeppeL-G added the bug Something isn't working label Nov 12, 2021
@PeppeL-G
Copy link
Author

To debug this, I tried to use {{line.code}} instead of {{codeBlock line.code}}. For the comment where the code was shown before, the following is now shown:

          <pre><code id="code-block-3-0">PGgyPkFsbCBIdW1hbnM8L2gyPgp7eyNpZiBodW1hbnMubGVuZ3RofX0KICA8dWw+CiAgICB7eyNlYWNoIGh1bWFuc319CiAgICAgIDxsaT57e25hbWV9fTwvbGk+CiAgICB7ey9lYWNofX0KICA8L3VsPgp7e2Vsc2V9fQogIDxwPk5vIGh1bWFucyBleGlzdC48L3A+Cnt7L2lmfX0K</code></pre>

For all others, nothing is shown:

<pre><code id="code-block-4-0"></code></pre>

@PeppeL-G
Copy link
Author

Oh, now I know the problem. I'm a teacher, and students email me their projects as ZIP files, which I then unzip on my computer and open in VS Code, and then I use this extension to do a Code Review on their work.

Some students use Mac, and I use Windows. In their files on my computer, LF is used for newlines, and that's what's causing this extension to mail function when generating the report. If I in VS Code change to CRLF for a file and then generate the report again, the code from that file shows in the report.

That the code was shown for one of my comments was because that's a file I've created on my Windows computer and published on the web for the students to learn, so in that one newlines was already represented as CRLF.

Someone who want's to create an extension that changes LF to CRLF in all files in the opened folder? xD Guess I should be able to do a clever find and replace all of some kind.

Otherwise, excellent extension, it was precisely what I was looking for, thank you!

@PeppeL-G
Copy link
Author

Won't you look at that.

https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.keyoti-changeallendoflinesequence

It's a big world we live in :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant