Skip to content

Commit fb9a351

Browse files
committed
Fix IDE0059 Value assigned is never used (includes a bugfix)
1 parent c1c420d commit fb9a351

13 files changed

Lines changed: 10 additions & 33 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1626CodeFixProvider.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
5353

5454
private static async Task<Document> GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
5555
{
56-
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
5756
var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
5857

5958
TextChange textChange = new TextChange(new TextSpan(diagnostic.Location.SourceSpan.Start, 1), string.Empty);

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1642SA1643CodeFixProvider.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ private static Task<Document> GetTransformedDocumentAsync(Document document, Syn
174174
private static Task<Document> GetTransformedDocumentAsync(Document document, SyntaxNode root, XmlEmptyElementSyntax node)
175175
{
176176
var typeDeclaration = node.FirstAncestorOrSelf<BaseTypeDeclarationSyntax>();
177-
var declarationSyntax = node.FirstAncestorOrSelf<BaseMethodDeclarationSyntax>();
178-
bool isStruct = typeDeclaration.IsKind(SyntaxKind.StructDeclaration);
179177

180178
TypeParameterListSyntax typeParameterList;
181179
if (typeDeclaration is ClassDeclarationSyntax classDeclaration)

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/FormattingHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static SyntaxTrivia WithoutFormatting(this SyntaxTrivia trivia)
9292
}
9393
}
9494

95-
return WithoutFormattingImpl(trivia);
95+
return WithoutFormattingImpl(result);
9696
}
9797

9898
/// <summary>

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1129CodeFixProvider.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ private static SyntaxNode GetReplacementNode(SyntaxNode node, SemanticModel sema
6565
var symbolInfo = semanticModel.GetSymbolInfo(newExpression.Type, cancellationToken);
6666
var namedTypeSymbol = symbolInfo.Symbol as INamedTypeSymbol;
6767

68-
SyntaxNode replacement = null;
69-
string memberName = null;
68+
SyntaxNode replacement;
7069

7170
if (IsType<CancellationToken>(namedTypeSymbol))
7271
{
@@ -79,7 +78,7 @@ private static SyntaxNode GetReplacementNode(SyntaxNode node, SemanticModel sema
7978
replacement = ConstructMemberAccessSyntax(newExpression.Type, nameof(CancellationToken.None));
8079
}
8180
}
82-
else if (IsEnumWithDefaultMember(namedTypeSymbol, out memberName))
81+
else if (IsEnumWithDefaultMember(namedTypeSymbol, out string memberName))
8382
{
8483
replacement = ConstructMemberAccessSyntax(newExpression.Type, memberName);
8584
}

StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/IndentationHelperTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private static Document CreateTestDocument(string source, int indentationSize =
179179
}}
180180
}}
181181
";
182-
var settingsDocumentId = DocumentId.CreateNewId(projectId);
182+
183183
solution = solution.AddAdditionalDocument(documentId, SettingsHelper.SettingsFileName, settings);
184184
}
185185

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PartialElementDocumentationSummaryBase.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,6 @@ private string ExpandDocumentation(Compilation compilation, DocumentationComment
168168

169169
sb.AppendLine("<member>");
170170

171-
var documentationChildren = new List<XElement>();
172-
173171
foreach (XmlNodeSyntax xmlNode in documentCommentTrivia.Content)
174172
{
175173
if (xmlNode == includeTag)

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1643DestructorSummaryDocumentationMustBeginWithStandardText.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public override void Initialize(AnalysisContext context)
7878

7979
private static void HandleDestructor(SyntaxNodeAnalysisContext context)
8080
{
81-
var destructorDeclaration = (DestructorDeclarationSyntax)context.Node;
8281
var settings = context.Options.GetStyleCopSettings(context.CancellationToken);
8382
var culture = new CultureInfo(settings.DocumentationRules.DocumentationCulture);
8483
var resourceManager = DocumentationResources.ResourceManager;

StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XmlCommentHelper.cs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,13 @@ internal static bool IsConsideredEmpty(XmlNodeSyntax xmlSyntax, bool considerEmp
122122
return true;
123123
}
124124

125-
if (xmlSyntax is XmlEmptyElementSyntax emptyElement)
125+
if (xmlSyntax is XmlEmptyElementSyntax)
126126
{
127127
// This includes <inheritdoc/>
128128
return considerEmptyElements;
129129
}
130130

131-
if (xmlSyntax is XmlProcessingInstructionSyntax processingElement)
132-
{
133-
return false;
134-
}
135-
136-
return true;
131+
return !(xmlSyntax is XmlProcessingInstructionSyntax);
137132
}
138133

139134
/// <summary>
@@ -162,12 +157,7 @@ internal static bool IsConsideredEmpty(XNode node)
162157
return true;
163158
}
164159

165-
if (node is XProcessingInstruction processingElement)
166-
{
167-
return false;
168-
}
169-
170-
return true;
160+
return !(node is XProcessingInstruction);
171161
}
172162

173163
/// <summary>

StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1516ElementsMustBeSeparatedByBlankLine.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@ private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, Sty
204204
{
205205
ReportIfThereIsNoBlankLine(context, previousItem, members[0]);
206206
}
207-
208-
previousItem = members.Last();
209207
}
210208
}
211209

StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1119StatementMustNotUseUnnecessaryParenthesis.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private static void HandleParenthesizedExpression(SyntaxNodeAnalysisContext cont
161161
}
162162
else
163163
{
164-
if (node.Parent is AssignmentExpressionSyntax assignValue)
164+
if (node.Parent is AssignmentExpressionSyntax)
165165
{
166166
ReportDiagnostic(context, node);
167167
}

0 commit comments

Comments
 (0)