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

Rule S1134 and Rule S1135: Track uses of 'FIXME' and 'TODO' #2250

Merged
merged 3 commits into from
Jan 30, 2019

Conversation

Evangelink
Copy link
Contributor

Fix #2041 and Fix #2042

@ghost ghost assigned Evangelink Jan 29, 2019
@ghost ghost added the Status: Needs Review label Jan 29, 2019
@Evangelink Evangelink changed the title Rule S1134 and Rule S1135: Track uses of 'FIXME' and 'TODO' [WIP] Rule S1134 and Rule S1135: Track uses of 'FIXME' and 'TODO' Jan 29, 2019
@@ -346,5 +346,20 @@ public static bool IsLeftSideOfAssignment(this ExpressionSyntax expression)
topParenthesizedExpression.Parent is AssignmentExpressionSyntax assignment &&
assignment.Left == topParenthesizedExpression;
}

public static bool IsComment(this SyntaxTrivia trivia)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was duplicated by the Fixme rule, the Todo rule and the comment metrics analyzers.

}
}

private static bool IsWordAt(string text, int index, int count)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic was already there before, it was just moved.

});
}

private static IEnumerable<int> AllIndexesOf(string text, string value, StringComparison comparisonType = StringComparison.OrdinalIgnoreCase)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic was already there before, it was just moved.

NB: I extracted the comparison type as a parameter with a default value.


Namespace Tests.TestCases
''' <summary>
''' TODO: Do something ' Noncompliant
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot test for the issue message because it contains the word TODO in a comment and so triggers another issue on the same line which looks really odd when reviewing.


Namespace Tests.TestCases
''' <summary>
''' FIXME: Do something ' Noncompliant
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot test for the issue message because it contains the word FIXME in a comment and so triggers another issue on the same line which looks really odd when reviewing.

@Evangelink Evangelink changed the title [WIP] Rule S1134 and Rule S1135: Track uses of 'FIXME' and 'TODO' Rule S1134 and Rule S1135: Track uses of 'FIXME' and 'TODO' Jan 29, 2019
Copy link
Contributor

@andrei-epure-sonarsource andrei-epure-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments left

{
public abstract class CommentKeywordBase : SonarDiagnosticAnalyzer
{
private const string TODO_Keyword = "TODO";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these being constants, you could use ALL_CAPS (mixing ALL_CAPS with PascalCase looks ugly)

protected const string FIXME_DiagnosticId = "S1134";
protected const string FIXME_MessageFormat = "Take the required action to fix the issue indicated by this '" + FIXME_Keyword + "' comment.";

protected abstract DiagnosticDescriptor TODO_Diagnostic { get; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just name it {Todo,Fixme}Diagnostic (there's no reason to use underscores)

Imports System.Linq
Imports System.Text

Namespace Tests.TestCases
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a ClassName FIXME and a variable FIXME (just to make sure)

Imports System.Linq
Imports System.Text

Namespace Tests.TestCases
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a ClassName TODO and a variable TODO (just to make sure)

Copy link
Contributor

@andrei-epure-sonarsource andrei-epure-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@andrei-epure-sonarsource andrei-epure-sonarsource merged commit fc3d406 into master Jan 30, 2019
@ghost ghost removed the Status: Needs Review label Jan 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants