Skip to content

Commit

Permalink
refactoring code
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Login <[email protected]>
  • Loading branch information
batazor committed Oct 25, 2023
1 parent 113c56f commit 382183b
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 12 deletions.
5 changes: 4 additions & 1 deletion .github/linters/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ run:
# Default: true
tests: true

skip-dirs:
- "internal/services/shortdb/io_uring"

skip-files:
- ".*mocks.+"
- "wire_gen.go"
- "io_uring.go"

# If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
Expand Down Expand Up @@ -140,6 +142,7 @@ linters-settings:

disabled-checks:
- paramTypeCombine
- dynamicFmtString
- appendAssign
- ifElseChain
- singleCaseSwitch
Expand Down
5 changes: 4 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ run:
# Default: true
tests: true

skip-dirs:
- "internal/services/shortdb/io_uring"

skip-files:
- ".*mocks.+"
- "wire_gen.go"
- "io_uring.go"

# If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
Expand Down Expand Up @@ -140,6 +142,7 @@ linters-settings:

disabled-checks:
- paramTypeCombine
- dynamicFmtString
- appendAssign
- ifElseChain
- singleCaseSwitch
Expand Down
5 changes: 2 additions & 3 deletions internal/di/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type Service struct {
AutoMaxPro autoMaxPro.AutoMaxPro
}

// Default =============================================================================================================
// DefaultSet ==========================================================================================================
var DefaultSet = wire.NewSet(
shortctx.New,
autoMaxPro.New,
Expand All @@ -72,7 +72,7 @@ var DefaultSet = wire.NewSet(
permission.New,
)

// FullService =========================================================================================================
// FullSet =============================================================================================================
var FullSet = wire.NewSet(
DefaultSet,
NewFullService,
Expand Down Expand Up @@ -102,7 +102,6 @@ func NewFullService(
pprofHTTP profiling.PprofEndpoint,
autoMaxProcsOption autoMaxPro.AutoMaxPro,
) (*Service, error) {

return &Service{
// Common
Ctx: ctx,
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/rpc/middleware/logger/client_interceptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func StreamClientInterceptor(log logger.Logger) grpc.StreamClientInterceptor {
streamer grpc.Streamer,
opts ...grpc.CallOption,
) (grpc.ClientStream, error) {

clientStream, err := streamer(ctx, desc, cc, method, opts...)
fields := field.Fields{
"grpc.service": path.Dir(method)[1:],
Expand Down
2 changes: 2 additions & 0 deletions internal/pkg/rpc/middleware/session/client_interceptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func SessionUnaryInterceptor() grpc.UnaryClientInterceptor {
invoker grpc.UnaryInvoker,
opts ...grpc.CallOption,
) (err error) {

sess := session.GetSession(ctx)

ctx = metadata.AppendToOutgoingContext(ctx, "user-id", sess.GetId())
Expand All @@ -38,6 +39,7 @@ func SessionStreamInterceptor() grpc.StreamClientInterceptor {
streamer grpc.Streamer,
opts ...grpc.CallOption,
) (grpc.ClientStream, error) {

sess := session.GetSession(ctx)

ctx = metadata.AppendToOutgoingContext(ctx, "user-id", sess.GetId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func (api *API) Run(
paymentService *payment_application.PaymentService,
tariffService *tariff_application.TariffService,
) error {

api.ctx = ctx
api.jsonpb = protojson.MarshalOptions{
UseProtoNames: true,
Expand Down
2 changes: 1 addition & 1 deletion internal/services/link/infrastructure/rpc/link/v1/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb" //nolint:imports // false positive
"google.golang.org/protobuf/types/known/emptypb"

queryStore "github.com/shortlink-org/shortlink/internal/services/link/infrastructure/store/crud/query"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/Masterminds/squirrel"
"github.com/jackc/pgx/v5/pgxpool"
"google.golang.org/protobuf/types/known/timestamppb" //nolint:imports // false positive
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/shortlink-org/shortlink/internal/pkg/db"
v1 "github.com/shortlink-org/shortlink/internal/services/link/domain/link/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
_ "github.com/lib/pq" // need for init PostgreSQL interface
"github.com/spf13/viper"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/types/known/timestamppb" //nolint:imports // false positive
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/shortlink-org/shortlink/internal/pkg/batch"
"github.com/shortlink-org/shortlink/internal/pkg/db"
Expand Down
4 changes: 2 additions & 2 deletions internal/services/shortdb/parser/v1/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (p *Parser) Parse() (*query.Query, error) {
}

if p.GetError() != "" {
return nil, fmt.Errorf(p.Error)
return nil, fmt.Errorf(p.GetError())
}

return q, nil
Expand All @@ -91,7 +91,7 @@ func (p *Parser) Parse() (*query.Query, error) {
func (p *Parser) doParse() (*query.Query, error) { //nolint:gocyclo,gocognit,maintidx,revive,cyclop // TODO: refactor
for {
if p.GetI() >= int32(len(p.GetSql())) {
return p.Query, fmt.Errorf(p.Error)
return p.GetQuery(), fmt.Errorf(p.GetError())
}

switch p.GetStep() {
Expand Down
3 changes: 2 additions & 1 deletion ops/gitlab/pipelines/test/golang.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include:
# https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/lib/gitlab/ci/templates/Security/Coverage-Fuzzing.gitlab-ci.yml
- template: Security/Coverage-Fuzzing.gitlab-ci.yml
- template: Jobs/Code-Intelligence.gitlab-ci.yml
- local: /ops/gitlab/templates/common.yml
Expand Down Expand Up @@ -79,7 +80,7 @@ go_fuzz_test:
script:
# link package
- GITLAB_COV_FUZZ_PATH=`pwd`
- cd $CI_PROJECT_DIR/internal/services/link/domain/link
- cd $CI_PROJECT_DIR/internal/services/link/domain/link/v1
- go-fuzz-build -libfuzzer -o link_fuzz_target.a .
- clang -fsanitize=fuzzer link_fuzz_target.a -o link_fuzz_target
- $GITLAB_COV_FUZZ_PATH/gitlab-cov-fuzz run --regression=$REGRESSION -- ./link_fuzz_target
Expand Down

0 comments on commit 382183b

Please sign in to comment.