Skip to content

Apply modernize suggestions#3

Closed
AnnaShaleva wants to merge 84 commits intovirtuald:masterfrom
nspcc-dev:modernize
Closed

Apply modernize suggestions#3
AnnaShaleva wants to merge 84 commits intovirtuald:masterfrom
nspcc-dev:modernize

Conversation

@AnnaShaleva
Copy link

AnnaShaleva and others added 30 commits September 15, 2021 12:59
encode: escape non-ASCII characters while marshalling
tables: escape apostrophe as well for C# compatibility
Ref. nspcc-dev/neo-go#3224.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
*: escape HTML chars into uppercase unicode bytes
No linting for this project, sorry. We'd better avoid merge conflicts
from the base repository.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
We're interested in the most fresh NeoGo-compatible versions.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
.github: take care of testing jobs
Ref nspcc-dev/neo-go#3284.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
tables: escape double quotes for C# compatibility
This makes encoding follow .NET JSON/UTF8 libraries as much as possible,
tested with

using System;
using System.IO;
using System.Text.Json;

public class Program
{
        public static void Main()
        {
                string controls = "\x00\x01";
                MemoryStream ms = new MemoryStream();
                Utf8JsonWriter writer = new Utf8JsonWriter(ms, new JsonWriterOptions
            {
                SkipValidation = true,
            });
                writer.WriteStringValue(controls);
                writer.Flush();
                byte[] res = ms.ToArray();
                string result = System.Text.Encoding.UTF8.GetString(res);
                Console.WriteLine(result);
        }
}

which is similar to what Neo does. Can't comment on differences much because
that's just the way .NET is, it doesn't use \ufffd, it escapes some controls in
a different way, it just does what it wants and we have to follow here to be
compatible.

Notice that C# `\x` escaping differs from Go significantly if you want to play
with it (it's `\xH[H][H][H]` instead of `\xHH`). It also interprets bytes a bit
differently.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Seems like they're so old they can't be executed. Drop useless actions at
the same time.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
It's available since Go 1.9.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
We don't need virtuald variant here.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Hi, Go 1.18.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
encode.go:743:12   errcheck     Error return value of `enc.Write` is not checked

It's not very likely (bytes.ErrTooLarge maybe), but this code runs inside a
defer/recover, so we can handle it this way.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
roman-khimov and others added 29 commits August 28, 2024 22:51
And use 1.23 for tests now. Fixes #10.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
  level=warning msg="The linter 'exportloopref' is deprecated (since v1.60.2) due to: Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar."

Signed-off-by: Roman Khimov <roman@nspcc.ru>
  Error: SA1019: reflect.PtrTo has been deprecated since Go 1.22 and an alternative has been available since Go 1.18: Superseded by [PointerTo].  (staticcheck)

These methods are exactly the same.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
No Makefile here, so just a GH update.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
workflows: switch to org-wide linter
Support for macos-12 will be deprecated 10/7/24 and the image will
be fully unsupported by 12/3/24. Ref.
actions/runner-images#10721.

Get rid of the build warning:
```
A brownout will take place on November 4, 14:00 UTC - November 5, 00:00
UTC to raise awareness of the upcoming macOS-12 environment removal.
```

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
workflows: drop macos-12 runner support
Signed-off-by: Roman Khimov <roman@nspcc.ru>
v2 is obsolete and no longer supported.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
1.22 is obsolete.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)).

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
Could remove embedded field from selector.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
These things are done on purpose.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
Use https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize
to improve our code.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants