Skip to content

Commit

Permalink
qodana cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
b3b00 committed Jan 8, 2024
1 parent ea7a84d commit 1c51da8
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 29 deletions.
3 changes: 0 additions & 3 deletions src/sly/lexer/GenericLexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public Config()

public IEqualityComparer<string> KeyWordComparer =>
KeyWordIgnoreCase ? StringComparer.OrdinalIgnoreCase : null;

public IList<string> Modes { get; set; }
}

public LexerPostProcess<IN> LexerPostProcess { get; set; }
Expand Down Expand Up @@ -832,7 +830,6 @@ private void AddDoubleWhenDoubleTokenPresent(IN token, DateFormat format, char s
match.Result.SpanValue = value;
match.StringDelimiterChar = stringDelimiterChar;
match.IsString = true;
if (stringDelimiterChar != escapeStringDelimiterChar)
{
match.Result.SpanValue = diffCharEscaper(escapeStringDelimiterChar, stringDelimiterChar,
Expand Down
1 change: 0 additions & 1 deletion src/sly/lexer/LexerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ private static bool IsGenericLexer<IN>(Dictionary<IN, (List<LexemeAttribute> lex
var modesAttribute = typeof(IN).GetCustomAttribute<ModesAttribute>();
if (modesAttribute != null)
{
config.Modes = modesAttribute.Modes;
}

var statics = new List<GenericToken>();
Expand Down
3 changes: 0 additions & 3 deletions src/sly/lexer/attributes/PopAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ 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 string TargetMode { get; }

public PopAttribute(string mode = null)
{
TargetMode = mode;
}
}
}
1 change: 0 additions & 1 deletion src/sly/lexer/fsm/FSMLexerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public FSMLexerBuilder()
CurrentState = 0;
Marks = new Dictionary<string, int>();
Fsm.AddNode(default(N));

Check notice on line 24 in src/sly/lexer/fsm/FSMLexerBuilder.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
Fsm.GetNode(0).IsStart = true;
}

public FSMLexer<N> Fsm { get; }
Expand Down
2 changes: 0 additions & 2 deletions src/sly/lexer/fsm/FSMMatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ public class FSMMatch<N> where N : struct
{
public Dictionary<string, object> Properties { get; }

public bool IsString { get; set; }

public char StringDelimiterChar { get; set; }

public char DecimalSeparator { get; set; }

Check notice on line 12 in src/sly/lexer/fsm/FSMMatch.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property can be made get-only (non-private accessibility)

Auto-property can be made get-only
Expand Down
5 changes: 2 additions & 3 deletions src/sly/lexer/fsm/FSMNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ internal FSMNode(N value)

internal N Value { get; set; }

internal int Id { get; set; } = 0;
internal int Id { get; set; }

internal bool IsEnd { get; set; } = false;
internal bool IsEnd { get; set; }

internal bool IsStart { get; set; } = false;
public string Mark { get; internal set; }
public bool IsLineEnding { get; set; }

Expand Down
15 changes: 6 additions & 9 deletions src/sly/parser/generator/ParserBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public ParserBuilder() : this(null)
{
var nt = "";

Check warning on line 172 in src/sly/parser/generator/ParserBuilder.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

Check notice on line 172 in src/sly/parser/generator/ParserBuilder.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Local variable has too wide declaration scope

Local variable 'nt' can be declared in inner scope
var rule = "";

Check warning on line 173 in src/sly/parser/generator/ParserBuilder.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

Check notice on line 173 in src/sly/parser/generator/ParserBuilder.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Local variable has too wide declaration scope

Local variable 'rule' can be declared in inner scope
var i = ruleString.IndexOf(":");
var i = ruleString.IndexOf(":", StringComparison.Ordinal);
if (i > 0)

Check notice on line 175 in src/sly/parser/generator/ParserBuilder.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Invert 'if' statement to reduce nesting

Invert 'if' statement to reduce nesting
{
nt = ruleString.Substring(0, i).Trim();
Expand All @@ -198,17 +198,15 @@ public ParserBuilder() : this(null)
protected virtual ParserConfiguration<IN, OUT> ExtractParserConfiguration(Type parserClass)
{
var conf = new ParserConfiguration<IN, OUT>();
var functions = new Dictionary<string, MethodInfo>();
var nonTerminals = new Dictionary<string, NonTerminal<IN>>();
var methods = parserClass.GetMethods().ToList<MethodInfo>();
methods = methods.Where<MethodInfo>(m =>
var methods = parserClass.GetMethods().ToList();
methods = methods.Where(m =>
{
var attributes = m.GetCustomAttributes().ToList<Attribute>();
var attributes = m.GetCustomAttributes().ToList();
var attr = attributes.Find(a => a.GetType() == typeof(ProductionAttribute));
return attr != null;
}).ToList<MethodInfo>();
}).ToList();

parserClass.GetMethods();
methods.ForEach(m =>
{
var attributes = (ProductionAttribute[])m.GetCustomAttributes(typeof(ProductionAttribute), true);
Expand All @@ -222,8 +220,7 @@ public ParserBuilder() : this(null)
r.SetVisitor(m);
r.NonTerminalName = ntAndRule.Item1;
var key = $"{ntAndRule.Item1}__{r.Key}";
functions[key] = m;
NonTerminal<IN> nonT = null;
NonTerminal<IN> nonT ;
if (!nonTerminals.ContainsKey(ntAndRule.Item1))

Check notice on line 224 in src/sly/parser/generator/ParserBuilder.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

'if' statement can be rewritten as '?:' expression

Convert into '?:' expression
nonT = new NonTerminal<IN>(ntAndRule.Item1, new List<Rule<IN>>());
else
Expand Down
6 changes: 3 additions & 3 deletions src/sly/parser/syntax/grammar/ChoiceClause.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public bool Equals(IClause<T> clause)
}

return false;
}
protected bool Equals(ChoiceClause<T> other)
}

private bool Equals(ChoiceClause<T> other)
{
if (other.Choices.Count != Choices.Count)
{
Expand Down
4 changes: 2 additions & 2 deletions src/sly/parser/syntax/grammar/NonTerminalClause.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public bool Equals(IClause<T> clause)

return false;
}
protected bool Equals(NonTerminalClause<T> other)

private bool Equals(NonTerminalClause<T> other)
{
return NonTerminalName == other.NonTerminalName && IsGroup == other.IsGroup;
}
Expand Down
4 changes: 2 additions & 2 deletions src/sly/parser/syntax/grammar/OptionClause.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public bool Equals(IClause<T> clause)
}
return false;
}
protected bool Equals(OptionClause<T> other)

private bool Equals(OptionClause<T> other)
{
return Equals(Clause, other.Clause);
}
Expand Down

0 comments on commit 1c51da8

Please sign in to comment.