diff --git a/.github/workflows/qodana_code_quality.yml b/.github/workflows/qodana_code_quality.yml deleted file mode 100644 index 8dd7308..0000000 --- a/.github/workflows/qodana_code_quality.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Qodana -on: - workflow_dispatch: - pull_request: - push: - branches: - - master - -jobs: - qodana: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: 'Qodana Scan' - uses: JetBrains/qodana-action@v2023.2 - env: - QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} \ No newline at end of file diff --git a/Linguini.Bundle/FluentBundle.cs b/Linguini.Bundle/FluentBundle.cs index 1e8d75e..ad1398f 100644 --- a/Linguini.Bundle/FluentBundle.cs +++ b/Linguini.Bundle/FluentBundle.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -258,10 +257,6 @@ private bool TryInsert(string funcName, ExternalFunction fluentFunction, { switch (behavior) { -#if NET5_0_OR_GREATER - case InsertBehavior.None: - return _funcList.TryAdd(funcName, fluentFunction); -#else case InsertBehavior.None: if (!_funcList.ContainsKey(funcName)) { @@ -270,7 +265,6 @@ private bool TryInsert(string funcName, ExternalFunction fluentFunction, } return false; -#endif case InsertBehavior.OverwriteExisting: _funcList[funcName] = fluentFunction; break; diff --git a/Linguini.Shared/Util/ZeroCopyUtil.cs b/Linguini.Shared/Util/ZeroCopyUtil.cs index 5b12732..10b8bc8 100644 --- a/Linguini.Shared/Util/ZeroCopyUtil.cs +++ b/Linguini.Shared/Util/ZeroCopyUtil.cs @@ -1,6 +1,4 @@ using System; -using System.Diagnostics; -using System.Runtime.InteropServices; namespace Linguini.Shared.Util { @@ -87,7 +85,7 @@ public static bool IsOneOf(this char c, char c1, char c2, char c3, char c4) return c == c1 || c == c2 || c == c3 || c == c4; } -#if !NET5_0_OR_GREATER +#if NETSTANDARD2_1 // Polyfill for netstandard 2.1 until dotnet backports MemoryExtension public static ReadOnlyMemory TrimEndPolyFill(this ReadOnlyMemory memory) => memory.Slice(0, FindLastWhitespace(memory.Span)); diff --git a/Linguini.Syntax/Parser/LinguiniParser.cs b/Linguini.Syntax/Parser/LinguiniParser.cs index 99be045..7c7093e 100644 --- a/Linguini.Syntax/Parser/LinguiniParser.cs +++ b/Linguini.Syntax/Parser/LinguiniParser.cs @@ -1,5 +1,4 @@ -#nullable enable - + using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -21,7 +20,7 @@ public class LinguiniParser { private readonly ZeroCopyReader _reader; private readonly bool _enableExperimental; - private const string CR = "\n"; + private const string Cr = "\n"; /// /// Set input to string @@ -609,11 +608,11 @@ private bool TryGetPattern(out Pattern? pattern, out ParseError? error) ReadOnlyMemory value; if (textLiteral.MissingEol && textLiteral.Start == textLiteral.End) { - value = CR.AsMemory(); + value = Cr.AsMemory(); } else if (textLiteral.MissingEol && textLiteral.Start != textLiteral.End) { - var str = _reader.ReadSlice(start, end) + CR; + var str = _reader.ReadSlice(start, end) + Cr; value = str.AsMemory(); } else @@ -623,10 +622,10 @@ private bool TryGetPattern(out Pattern? pattern, out ParseError? error) if (lastNonBlank == i) { -#if NET5_0_OR_GREATER - value = value.TrimEnd(); -#else +#if NETSTANDARD2_1 value = value.TrimEndPolyFill(); +#else + value = value.TrimEnd(); #endif } @@ -772,7 +771,7 @@ private List GetAttributes() private bool TryGetAttribute([NotNullWhen(true)] out Attribute? attr) { - if (!TryGetIdentifier(out var id, out var err)) + if (!TryGetIdentifier(out var id, out _)) { attr = default!; return false; @@ -780,13 +779,13 @@ private bool TryGetAttribute([NotNullWhen(true)] out Attribute? attr) _reader.SkipBlankInline(); - if (!TryExpectChar('=', out err)) + if (!TryExpectChar('=', out _)) { attr = default!; return false; } - if (TryGetPattern(out var pattern, out err) && pattern != null) + if (TryGetPattern(out var pattern, out _) && pattern != null) { attr = new Attribute(id, pattern); return true;