Skip to content

Commit

Permalink
qodana : remove unused variables , parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
b3b00 committed Jan 9, 2024
1 parent 1c51da8 commit 7c0f4ae
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 42 deletions.
26 changes: 1 addition & 25 deletions src/samples/ParserExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private static void TestThreadsafeGeneric()
}
catch (Exception e)
{
;
Console.WriteLine($"error {e.Message} : {e.StackTrace}");
}
});
t.Start();
Expand Down Expand Up @@ -1168,7 +1168,6 @@ private static void Main(string[] args)
Issue414();
Issue414Expr();
//Issue351();
//EscapeIt();
// TestIssue332();
//TestTemplateFor();
// testErrors();
Expand Down Expand Up @@ -1349,29 +1348,6 @@ private static void TestIssue332()

}

private static void EscapeIt()
{
char escape = '\\';
char delim = '"';
var value = "\\\"te\\\\\\\\st\\\"";
string newValue = "";
int i = 0;
while (i < value.Length)
{
char current = value[i];
if (current == escape)
{
i++;
}

newValue += value[i];
i++;

}

;
}

private static void Issue351()
{
var parserInstance = new ExpressionParser();
Expand Down
5 changes: 2 additions & 3 deletions src/sly/lexer/GenericLexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ public LexerResult<IN> Tokenize(ReadOnlyMemory<char> source)
LexerFsm = SetLexerMode(r, lexersStack);

var ignored = r.IgnoredTokens.Select(x =>
new Token<IN>(default(IN), x.SpanValue, x.Position, x.IsComment,
x.CommentType, x.Channel)).ToList();
new Token<IN>(default(IN), x.SpanValue, x.Position, x.CommentType, x.Channel)).ToList();

Check notice on line 162 in src/sly/lexer/GenericLexer.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Use preferred style of default value expression when type is not evident

Redundant type specification
tokens.AddRange(ignored);


Expand Down Expand Up @@ -208,7 +207,7 @@ public LexerResult<IN> Tokenize(ReadOnlyMemory<char> source)
LexerFsm = SetLexerMode(r, lexersStack);

ignored = r.IgnoredTokens.Select(x =>
new Token<IN>(default(IN), x.SpanValue, x.Position, x.IsComment,
new Token<IN>(default(IN), x.SpanValue, x.Position,

Check notice on line 210 in src/sly/lexer/GenericLexer.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Use preferred style of default value expression when type is not evident

Redundant type specification
x.CommentType, x.Channel, x.IsWhiteSpace, x.DecimalSeparator)).ToList();
tokens.AddRange(ignored);

Expand Down
4 changes: 2 additions & 2 deletions src/sly/lexer/LexerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private static BuildResult<ILexer<IN>> Build<IN>(Dictionary<IN, (List<LexemeAttr
}
else
{
result = BuildRegexLexer<IN>(attributes, result, lang);
result = BuildRegexLexer<IN>(attributes, result);

Check warning on line 170 in src/sly/lexer/LexerBuilder.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Redundant type arguments of method

Type argument specification is redundant
}
}
else if (hasGenericLexemes)
Expand Down Expand Up @@ -233,7 +233,7 @@ private static bool IsGenericLexer<IN>(Dictionary<IN, (List<LexemeAttribute> lex


private static BuildResult<ILexer<IN>> BuildRegexLexer<IN>(Dictionary<IN, (List<LexemeAttribute> lexemes,List<LexemeLabelAttribute> labels)> attributes,
BuildResult<ILexer<IN>> result, string lang = null) where IN : struct
BuildResult<ILexer<IN>> result) where IN : struct
{
var lexer = new Lexer<IN>();
foreach (var pair in attributes)
Expand Down
6 changes: 3 additions & 3 deletions src/sly/lexer/Token.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public class Token<T> where T:struct
public bool Notignored;


public Token(T token, string value, LexerPosition position, bool isCommentStart = false,
CommentType commentType = CommentType.Single, int? channel = null, char decimalSeparator = '.' ) : this(token,new ReadOnlyMemory<char>(value.ToCharArray()),position,isCommentStart,commentType,channel, decimalSeparator:decimalSeparator)
public Token(T token, string value, LexerPosition position,
CommentType commentType = CommentType.Single, int? channel = null, char decimalSeparator = '.' ) : this(token,new ReadOnlyMemory<char>(value.ToCharArray()),position,commentType,channel, decimalSeparator:decimalSeparator)

{
}

public Token(T token, ReadOnlyMemory<char> value, LexerPosition position, bool isCommentStart = false,
public Token(T token, ReadOnlyMemory<char> value, LexerPosition position,
CommentType commentType = CommentType.Single, int? channel = null, bool isWhiteSpace = false, char decimalSeparator = '.' )
{
IsWhiteSpace = isWhiteSpace;
Expand Down
2 changes: 1 addition & 1 deletion src/sly/lexer/attributes/PopAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace sly.lexer
[AttributeUsage(AttributeTargets.Field)]
public class PopAttribute : Attribute

Check notice on line 6 in src/sly/lexer/attributes/PopAttribute.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Class is never instantiated (non-private accessibility)

Class 'PopAttribute' is never instantiated
{
public PopAttribute(string mode = null)
public PopAttribute()

Check warning on line 8 in src/sly/lexer/attributes/PopAttribute.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Empty constructor

Empty constructor is redundant. The compiler generates the same by default.
{
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sly/lexer/fsm/FSMLexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ private List<Token<N>> ConsumeIgnored(ReadOnlyMemory<char> source, LexerPosition
var currentCharacter = source.At<char>(position.Index);

Check warning on line 452 in src/sly/lexer/fsm/FSMLexer.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Redundant type arguments of method

Type argument specification is redundant
if (WhiteSpaces.Contains(currentCharacter))
{
var whiteToken = new Token<N>(default(N), source.Slice(position.Index, 1), position, false,
var whiteToken = new Token<N>(default(N), source.Slice(position.Index, 1), position,

Check notice on line 455 in src/sly/lexer/fsm/FSMLexer.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Use preferred style of default value expression when type is not evident

Redundant type specification
CommentType.No,
Channels.WhiteSpaces, isWhiteSpace: true, decimalSeparator: DecimalSeparator);
ignoredTokens.Add(whiteToken);
Expand Down
14 changes: 7 additions & 7 deletions src/sly/parser/generator/RuleParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public IClause<IN> ChoicesOne(Token<EbnfTokenGeneric> head)
[Production("choices : STRING")]
public IClause<IN> ChoicesString(Token<EbnfTokenGeneric> head)

Check notice on line 92 in src/sly/parser/generator/RuleParser.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Type member is never used (non-private accessibility)

Method 'ChoicesString' is never used
{
var choice = BuildTerminalOrNonTerimal(head.Value, discard: false,explicitToken:true);
var choice = BuildTerminalOrNonTerimal(head.Value, discard: false);
return new ChoiceClause<IN>(choice);
}

Expand All @@ -105,7 +105,7 @@ public IClause<IN> ChoicesMany(Token<EbnfTokenGeneric> head, Token<EbnfTokenGene
[Production("choices : STRING OR choices ")]
public IClause<IN> ChoicesManyImplicit(Token<EbnfTokenGeneric> head, Token<EbnfTokenGeneric> discardOr, ChoiceClause<IN> tail)

Check notice on line 106 in src/sly/parser/generator/RuleParser.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Type member is never used (non-private accessibility)

Method 'ChoicesManyImplicit' is never used
{
var headClause = BuildTerminalOrNonTerimal(head.Value,discard:false,explicitToken:true);
var headClause = BuildTerminalOrNonTerimal(head.Value,discard:false);
return new ChoiceClause<IN>(headClause,tail.Choices);
}

Expand All @@ -119,13 +119,13 @@ public IClause<IN> SimpleClause(Token<EbnfTokenGeneric> id)

[Production("clause : STRING")]
public IClause<IN> ExplicitTokenClause(Token<EbnfTokenGeneric> explicitToken) {
var clause = BuildTerminalOrNonTerimal(explicitToken.Value,discard:false, explicitToken :true);
var clause = BuildTerminalOrNonTerimal(explicitToken.Value,discard:false);
return clause;
}

[Production("clause : STRING DISCARD")]
public IClause<IN> ExplicitTokenClauseDiscarded(Token<EbnfTokenGeneric> explicitToken, Token<EbnfTokenGeneric> discard) {

Check notice on line 127 in src/sly/parser/generator/RuleParser.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Type member is never used (non-private accessibility)

Method 'ExplicitTokenClauseDiscarded' is never used
var clause = BuildTerminalOrNonTerimal(explicitToken.Value,discard:true, explicitToken :true);
var clause = BuildTerminalOrNonTerimal(explicitToken.Value,discard:true);
return clause;
}

Expand Down Expand Up @@ -203,7 +203,7 @@ public GroupClause<IN> GroupClause(Token<EbnfTokenGeneric> id)
[Production("groupclause : STRING ")]
public GroupClause<IN> GroupClauseExplicit(Token<EbnfTokenGeneric> explicitToken)
{
var clause = BuildTerminalOrNonTerimal(explicitToken.Value,discard:true, explicitToken :true);
var clause = BuildTerminalOrNonTerimal(explicitToken.Value,discard:true);
return new GroupClause<IN>(clause);
}

Expand All @@ -220,7 +220,7 @@ public GroupClause<IN> GroupClauseDiscarded(Token<EbnfTokenGeneric> id, Token<Eb
[Production("groupclause : STRING DISCARD ")]
public GroupClause<IN> GroupClauseExplicitDiscarded(Token<EbnfTokenGeneric> explicitToken, Token<EbnfTokenGeneric> discarded)
{
var clause = BuildTerminalOrNonTerimal(explicitToken.Value, true, explicitToken:true);
var clause = BuildTerminalOrNonTerimal(explicitToken.Value, true);
return new GroupClause<IN>(clause);
}

Expand All @@ -235,7 +235,7 @@ public GroupClause<IN> GroupChoiceClause(ChoiceClause<IN> choices)
#endregion


private IClause<IN> BuildTerminalOrNonTerimal(string name, bool discard = false, bool explicitToken = false)
private IClause<IN> BuildTerminalOrNonTerimal(string name, bool discard = false)

Check notice on line 238 in src/sly/parser/generator/RuleParser.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Member can be made static (shared) (private accessibility)

Method 'BuildTerminalOrNonTerimal' can be made static
{

var token = default(IN);

Check warning on line 241 in src/sly/parser/generator/RuleParser.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Assignment is not used

Value assigned is not used in any execution path
Expand Down

0 comments on commit 7c0f4ae

Please sign in to comment.