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

S4663: Fix highlighting to remove underlying whitespaces #6725

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -62,10 +62,9 @@ private void CheckTrivia(SonarSyntaxTreeReportingContext context, IEnumerable<Sy

foreach (var partition in partitions.Where(trivia => trivia.Any() && trivia.All(x => string.IsNullOrWhiteSpace(GetCommentText(x)))))
{
var start = partition.First().GetLocation().SourceSpan.Start;
var end = partition.Last().GetLocation().SourceSpan.End;
var location = Location.Create(context.Tree, TextSpan.FromBounds(start, end));
context.ReportIssue(Diagnostic.Create(Rule, location));
var location = partition.First().GetLocation();
var secondary = partition.Skip(1).Select(x => x.GetLocation());
context.ReportIssue(Diagnostic.Create(Rule, location, secondary));
}
}

Expand Down
Expand Up @@ -10,7 +10,7 @@ public class SingleLine //

// Noncompliant@-2 (a lot of whitespace before)

//
//

// Noncompliant@-2 (a lot of whitespace after)

Expand Down Expand Up @@ -75,6 +75,8 @@ public class SingleLine //
//
/// text
// Noncompliant@-4
// Secondary@-4
// Secondary@-4

//
//
Expand All @@ -83,6 +85,8 @@ public class SingleLine //
* text
*/
// Noncompliant@-6
// Secondary@-6
// Secondary@-6

//
//
Expand All @@ -91,10 +95,14 @@ public class SingleLine //
* text
*/
// Noncompliant@-6
// Secondary@-6
// Secondary@-6

void Method()
{
// Noncompliant@+2
// Noncompliant@+4
// Secondary@+4
// Secondary@+4

//
//
Expand All @@ -106,6 +114,8 @@ void Method()

// Noncompliant@-5
// Noncompliant@-5
// Secondary@-5
// Secondary@-5

//
//
Expand Down Expand Up @@ -136,7 +146,7 @@ public class SingleLineDocumentation ///
///
// Noncompliant@-1 (a lot of whitespace before)

///
///
// Noncompliant@-1 (a lot of whitespace after)

///
Expand Down Expand Up @@ -188,7 +198,7 @@ public class MultiLine /* */
/* */
// Noncompliant@-1 (a lot of whitespace inside)

/**/
/**/
// Noncompliant@-1 (a lot of whitespace after)

// Noncompliant@+1
Expand Down Expand Up @@ -286,7 +296,7 @@ public class MultiLineDocumentation /** */
/** */
// Noncompliant@-1 (a lot of whitespace inside)

/***/
/***/
// Noncompliant@-1 (a lot of whitespace after)

// Noncompliant@+1
Expand Down Expand Up @@ -381,7 +391,9 @@ hey there
///


// Noncompliant@+2
// Noncompliant@+4
// Secondary@+4
// Secondary@+4

//
//
Expand Down
Expand Up @@ -14,7 +14,7 @@
Dim b = 42 ''' Ipsem Lorum
Dim c = 42 '''

'
'

' Noncompliant@-2 (whitespace)

Expand All @@ -29,13 +29,17 @@
'
'

' Noncompliant@+2

'
'
'
'

' Noncompliant@-5
' Secondary@-5
' Secondary@-5
' Secondary@-5

' Noncompliant@+2

'
Expand All @@ -45,6 +49,8 @@
'

' Noncompliant@-4
' Secondary@-4
' Secondary@-4

' *
' Ipsem Lorum
Expand Down Expand Up @@ -80,10 +86,12 @@
'
''' Ipsem Lorum
' Noncompliant@-4
' Secondary@-4
' Secondary@-4
End Sub

Public Sub DocumentationComment()
'''
'''
' Noncompliant@-1 (whitespace)

''' *
Expand Down Expand Up @@ -133,12 +141,15 @@ End Class
'''


' Noncompliant@+2

'
'
'

' Noncompliant@-4
' Secondary@-4
' Secondary@-4

' Noncompliant@+1
'''
'''