Skip to content

Commit

Permalink
sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
b3b00 committed Mar 4, 2024
1 parent 74767ca commit 803415b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/sly/lexer/TokenChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,27 @@ public class TokenChannel<IN> where IN : struct
{
public readonly List<Token<IN>> Tokens;

public List<Token<IN>> NotNullTokens => Tokens.Where(x => x != null).ToList();
private List<Token<IN>> _notNullTokens = new List<Token<IN>>();

Check warning on line 12 in src/sly/lexer/TokenChannel.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Member initialized value ignored

Field initializer value ignored during initialization

public List<Token<IN>> NotNullTokens => _notNullTokens;

Check notice on line 14 in src/sly/lexer/TokenChannel.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Convert property into auto-property with private setter

Convert into auto-property with private setter

Check notice on line 14 in src/sly/lexer/TokenChannel.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Type member is never used (non-private accessibility)

Property 'NotNullTokens' is never used

public List<Token<IN>> NotNullOrEosTokens => Tokens.Where(x => x != null && !x.IsEOS).ToList();
private List<Token<IN>> _notNullOrEosTokens;
public List<Token<IN>> NotNullOrEosTokens => _notNullOrEosTokens;

Check notice on line 17 in src/sly/lexer/TokenChannel.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Convert property into auto-property with private setter

Convert into auto-property with private setter

public int ChannelId;

Check notice on line 19 in src/sly/lexer/TokenChannel.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Field can be made readonly (non-private accessibility)

Field can be made readonly
public int Count => Tokens.Count;

public TokenChannel(List<Token<IN>> tokens, int channelId)

Check notice on line 22 in src/sly/lexer/TokenChannel.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Member can be made private (non-private accessibility)

Constructor 'TokenChannel' can be made private
{
Tokens = tokens;
_notNullTokens = tokens.Where(x => x != null).ToList();
_notNullOrEosTokens = tokens.Where(x => x != null && !x.IsEOS).ToList();
ChannelId = channelId;
}

public TokenChannel(int channelId) : this(new List<Token<IN>>(),channelId)
public TokenChannel(int channelId) : this(new List<Token<IN>>(), channelId)
{

}

private Token<IN> GetToken(int i)
Expand All @@ -41,6 +47,8 @@ private void SetToken(int i, Token<IN> token)
}
}
Tokens[i] = token;
_notNullTokens = Tokens.Where(x => x != null).ToList();
_notNullOrEosTokens = Tokens.Where(x => x != null && !x.IsEOS).ToList();
}

public Token<IN> this[int key]
Expand All @@ -54,6 +62,8 @@ public void Add(Token<IN> token)
Tokens.Add(token);
if (token != null)
token.PositionInTokenFlow = Tokens.Count;
_notNullTokens = Tokens.Where(x => x != null).ToList();
_notNullOrEosTokens = Tokens.Where(x => x != null && !x.IsEOS).ToList();
}

[ExcludeFromCodeCoverage]
Expand Down

0 comments on commit 803415b

Please sign in to comment.