Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Issues with an offset but without line information are ignored #176

Closed
pascalberger opened this issue Jul 12, 2021 · 6 comments
Closed

Issues with an offset but without line information are ignored #176

pascalberger opened this issue Jul 12, 2021 · 6 comments
Labels
Milestone

Comments

@pascalberger
Copy link
Member

pascalberger commented Jul 12, 2021

InspectCode can return issues without a line attribute, but with offset information. With current implementation these issues are ignored. For the following report no issues are returned:

"<?xml version="1.0" encoding="utf-8"?>
<!-- Generated by JetBrains Inspect Code 2021.1.3 -->

<Report ToolsVersion="211.0.20210525.205200">
    <Information>
        <Solution>Temp.sln</Solution>
        <InspectionScope>
            <Element>Solution</Element>
        </InspectionScope>
    </Information>
    <IssueTypes>
        <IssueType Id="RedundantUsingDirective" Category="Redundancies in Code" CategoryId="CodeRedundancy" Description="Redundant using directive" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=RedundantUsingDirective" />
    </IssueTypes>
    <Issues>
        <Project Name="Project1">
            <Issue TypeId="RedundantUsingDirective" File="Src\myfile.cs" Offset="0-48" Message="Using directive is not required by the code and can be safely removed" />
        </Project>
        <Project Name="Project2">
            <Issue TypeId="RedundantUsingDirective" File="Src\anotherfile.cs" Offset="0-23" Message="Using directive is not required by the code and can be safely removed" />
        </Project>
    </Issues>
</Report>"
@pascalberger pascalberger added this to the 1.0.0 milestone Jul 12, 2021
@janniksam
Copy link

janniksam commented Jul 12, 2021

It appears like InspectCode is not adding the line attribute when the issue is at the very first line.
I have added two redundant usings to a file.

InspectCode gives us the following output:

<Project Name="MyProject">
   <Issue TypeId="RedundantUsingDirective" File="Src\myfile.cs" Offset="0-48" Message="Using directive is not required by the code and can be safely removed"/>
   <Issue TypeId="RedundantUsingDirective" File="Src\myfile.cs" Offset="50-88" Line="2" Message="Using directive is not required by the code and can be safely removed"/>
</Project>
<Project Name="MyProject">
   <Issue TypeId="RedundantUsingDirective"  File="Src\anotherfile.cs" Offset="0-23" Message="Using directive is not required by the code and can be safely removed"/>
</Project>

For the issue on the very first line of a file, the line attribute is not added to the issue.

By the way: Any chance we would get this hotfixed in the current 0.9?

@pascalberger pascalberger modified the milestones: 1.0.0, 0.9.1 Jul 12, 2021
@pascalberger
Copy link
Member Author

@janniksam Do you think the following logic would work:

  • If no Line and no Offset attribute issue no line/column information will be read
  • If Line attribute but no Offset attribute issue is provided we'll read line information from Line, but not read column information
  • If Offset attribute but no Line attribute issue is provided we'll assume line as 1 and read column information from Offset
  • If Line and Offset attribute but is provided we'll read line information from Line and column information from Offset

I reassigned it to a 0.9.1 milestone

@janniksam
Copy link

I dont't think we can use offset, can we? See my XML I dont think we can convert it to a column with the given information. I wouldn't invent column information in this version anyways.

@janniksam
Copy link

We should go with this right now:

  • If no Line and no Offset attribute issue no line/column information will be read
  • If Line attribute is filled, we'll read line information from Line
  • If Line attribute is not filled, but Offset attribute is filled, we'll assume line as 1.

@pascalberger
Copy link
Member Author

I dont't think we can use offset, can we? See my XML I dont think we can convert it to a column with the given information. I wouldn't invent column information in this version anyways.

My interpretation of Offset="50-88" is column=50 / endColumn=88. But agree this is another issue: cake-contrib/Cake.Issues#416

@janniksam
Copy link

janniksam commented Jul 12, 2021

I have to disagree. Its based from the start of the entire file. The second issue would be 0 - something to be useful in our case.

pascalberger added a commit to pascalberger/Cake.Issues.InspectCode that referenced this issue Jul 12, 2021
@pascalberger pascalberger changed the title Issues not related to a line are ignored Issues with an offset but without line information are ignored Jul 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants