Fix wsl_v5 lint errors and exclude node_modules from linting

This commit is contained in:
Émile Ré
2026-05-20 15:05:08 +04:00
parent ec2bbccdbd
commit 7ac77b85e9
25 changed files with 592 additions and 0 deletions

View File

@@ -59,6 +59,7 @@ func (ra *RiskAssessment) AuthorizationAttributes(ctx context.Context, conn pg.Q
if errors.Is(err, pgx.ErrNoRows) {
return nil, ErrResourceNotFound
}
return nil, fmt.Errorf("cannot query risk assessment authorization attributes: %w", err)
}
@@ -192,6 +193,7 @@ VALUES (@id, @tenant_id, @organization_id, @name, @description, @created_at, @up
if err != nil {
return fmt.Errorf("cannot insert risk assessment: %w", err)
}
return nil
}
@@ -246,5 +248,6 @@ DELETE FROM risk_assessments WHERE %s AND id = @id
maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args)
return err
}

View File

@@ -49,6 +49,7 @@ func (n *RiskAssessmentNode) CursorKey(orderBy RiskAssessmentNodeOrderField) pag
case RiskAssessmentNodeOrderFieldName:
return page.CursorKey{ID: n.ID, Value: n.Name}
}
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
}
@@ -60,6 +61,7 @@ func (n *RiskAssessmentNode) AuthorizationAttributes(ctx context.Context, conn p
if errors.Is(err, pgx.ErrNoRows) {
return nil, ErrResourceNotFound
}
return nil, fmt.Errorf("cannot query risk assessment node authorization attributes: %w", err)
}
@@ -98,11 +100,14 @@ WHERE
if err != nil {
return fmt.Errorf("cannot query risk assessment nodes: %w", err)
}
results, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[RiskAssessmentNode])
if err != nil {
return fmt.Errorf("cannot collect risk assessment nodes: %w", err)
}
*ns = results
return nil
}
@@ -137,11 +142,14 @@ ORDER BY
if err != nil {
return fmt.Errorf("cannot query risk assessment nodes: %w", err)
}
results, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[RiskAssessmentNode])
if err != nil {
return fmt.Errorf("cannot collect risk assessment nodes: %w", err)
}
*ns = results
return nil
}
@@ -169,6 +177,7 @@ WHERE
if err := conn.QueryRow(ctx, q, args).Scan(&count); err != nil {
return 0, fmt.Errorf("cannot count risk assessment nodes: %w", err)
}
return count, nil
}
@@ -197,14 +206,18 @@ LIMIT 1;
if err != nil {
return fmt.Errorf("cannot query risk assessment node: %w", err)
}
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[RiskAssessmentNode])
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound
}
return fmt.Errorf("cannot collect risk assessment node: %w", err)
}
*n = result
return nil
}
@@ -240,13 +253,16 @@ INSERT INTO risk_assessment_nodes (
"created_at": n.CreatedAt,
"updated_at": n.UpdatedAt,
}
_, err := conn.Exec(ctx, q, args)
if err != nil {
if pgErr, ok := errors.AsType[*pgconn.PgError](err); ok && pgErr.Code == "23505" && pgErr.ConstraintName == "risk_assessment_nodes_unique_name" {
return ErrResourceAlreadyExists
}
return fmt.Errorf("cannot insert risk assessment node: %w", err)
}
return nil
}
@@ -274,9 +290,11 @@ WHERE
if err != nil {
return fmt.Errorf("cannot update risk assessment node: %w", err)
}
if result.RowsAffected() == 0 {
return ErrResourceNotFound
}
return nil
}
@@ -292,5 +310,6 @@ WHERE
maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args)
return err
}

View File

@@ -50,6 +50,7 @@ func (p *RiskAssessmentProcess) CursorKey(orderBy RiskAssessmentProcessOrderFiel
case RiskAssessmentProcessOrderFieldName:
return page.CursorKey{ID: p.ID, Value: p.Name}
}
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
}
@@ -61,6 +62,7 @@ func (p *RiskAssessmentProcess) AuthorizationAttributes(ctx context.Context, con
if errors.Is(err, pgx.ErrNoRows) {
return nil, ErrResourceNotFound
}
return nil, fmt.Errorf("cannot query risk assessment process authorization attributes: %w", err)
}
@@ -100,11 +102,14 @@ WHERE
if err != nil {
return fmt.Errorf("cannot query risk assessment processes: %w", err)
}
results, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[RiskAssessmentProcess])
if err != nil {
return fmt.Errorf("cannot collect risk assessment processes: %w", err)
}
*ps = results
return nil
}
@@ -140,11 +145,14 @@ ORDER BY
if err != nil {
return fmt.Errorf("cannot query risk assessment processes: %w", err)
}
results, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[RiskAssessmentProcess])
if err != nil {
return fmt.Errorf("cannot collect risk assessment processes: %w", err)
}
*ps = results
return nil
}
@@ -172,6 +180,7 @@ WHERE
if err := conn.QueryRow(ctx, q, args).Scan(&count); err != nil {
return 0, fmt.Errorf("cannot count risk assessment processes: %w", err)
}
return count, nil
}
@@ -196,18 +205,23 @@ LIMIT 1;
q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"id": id}
maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot query risk assessment process: %w", err)
}
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[RiskAssessmentProcess])
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound
}
return fmt.Errorf("cannot collect risk assessment process: %w", err)
}
*p = result
return nil
}
@@ -246,13 +260,16 @@ INSERT INTO risk_assessment_processes (
"created_at": p.CreatedAt,
"updated_at": p.UpdatedAt,
}
_, err := conn.Exec(ctx, q, args)
if err != nil {
if pgErr, ok := errors.AsType[*pgconn.PgError](err); ok && pgErr.Code == "23505" && pgErr.ConstraintName == "risk_assessment_processes_unique_name" {
return ErrResourceAlreadyExists
}
return fmt.Errorf("cannot insert risk assessment process: %w", err)
}
return nil
}
@@ -277,13 +294,16 @@ WHERE
"updated_at": p.UpdatedAt,
}
maps.Copy(args, scope.SQLArguments())
result, err := conn.Exec(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot update risk assessment process: %w", err)
}
if result.RowsAffected() == 0 {
return ErrResourceNotFound
}
return nil
}
@@ -298,5 +318,6 @@ WHERE
args := pgx.StrictNamedArgs{"id": id}
maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args)
return err
}

View File

@@ -48,6 +48,7 @@ func (s *RiskAssessmentScenario) CursorKey(orderBy RiskAssessmentScenarioOrderFi
case RiskAssessmentScenarioOrderFieldName:
return page.CursorKey{ID: s.ID, Value: s.Name}
}
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
}
@@ -59,6 +60,7 @@ func (s *RiskAssessmentScenario) AuthorizationAttributes(ctx context.Context, co
if errors.Is(err, pgx.ErrNoRows) {
return nil, ErrResourceNotFound
}
return nil, fmt.Errorf("cannot query risk scenario authorization attributes: %w", err)
}
@@ -97,11 +99,14 @@ WHERE
if err != nil {
return fmt.Errorf("cannot query risk scenarios: %w", err)
}
results, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[RiskAssessmentScenario])
if err != nil {
return fmt.Errorf("cannot collect risk scenarios: %w", err)
}
*ss = results
return nil
}
@@ -128,6 +133,7 @@ WHERE
if err := conn.QueryRow(ctx, q, args).Scan(&count); err != nil {
return 0, fmt.Errorf("cannot count risk scenarios: %w", err)
}
return count, nil
}
@@ -172,11 +178,14 @@ WHERE
if err != nil {
return fmt.Errorf("cannot query risk scenarios: %w", err)
}
results, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[RiskAssessmentScenario])
if err != nil {
return fmt.Errorf("cannot collect risk scenarios: %w", err)
}
*ss = results
return nil
}
@@ -212,6 +221,7 @@ WHERE
if err := conn.QueryRow(ctx, q, args).Scan(&count); err != nil {
return 0, fmt.Errorf("cannot count risk scenarios: %w", err)
}
return count, nil
}
@@ -247,11 +257,14 @@ WHERE
if err != nil {
return fmt.Errorf("cannot query risk scenarios: %w", err)
}
results, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[RiskAssessmentScenario])
if err != nil {
return fmt.Errorf("cannot collect risk scenarios: %w", err)
}
*ss = results
return nil
}
@@ -278,6 +291,7 @@ WHERE
if err := conn.QueryRow(ctx, q, args).Scan(&count); err != nil {
return 0, fmt.Errorf("cannot count risk scenarios: %w", err)
}
return count, nil
}
@@ -301,18 +315,23 @@ LIMIT 1
q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"id": id}
maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot query risk scenario: %w", err)
}
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[RiskAssessmentScenario])
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound
}
return fmt.Errorf("cannot collect risk scenario: %w", err)
}
*s = result
return nil
}
@@ -348,10 +367,12 @@ INSERT INTO risk_assessment_scenarios (
"created_at": s.CreatedAt,
"updated_at": s.UpdatedAt,
}
_, err := conn.Exec(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot insert risk scenario: %w", err)
}
return nil
}
@@ -369,13 +390,16 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"id": s.ID, "name": s.Name, "description": s.Description, "updated_at": s.UpdatedAt}
maps.Copy(args, scope.SQLArguments())
result, err := conn.Exec(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot update risk scenario: %w", err)
}
if result.RowsAffected() == 0 {
return ErrResourceNotFound
}
return nil
}
@@ -390,5 +414,6 @@ WHERE
args := pgx.StrictNamedArgs{"id": id}
maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args)
return err
}

View File

@@ -58,13 +58,16 @@ INSERT INTO risk_assessment_scenario_risks (
"risk_id": sr.RiskID,
"created_at": sr.CreatedAt,
}
_, err := conn.Exec(ctx, q, args)
if err != nil {
if pgErr, ok := errors.AsType[*pgconn.PgError](err); ok && pgErr.Code == "23505" && pgErr.ConstraintName == "risk_assessment_scenario_risks_pkey" {
return ErrResourceAlreadyExists
}
return fmt.Errorf("cannot insert risk scenario risk: %w", err)
}
return nil
}
@@ -83,6 +86,7 @@ WHERE
}
maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args)
return err
}
@@ -137,11 +141,14 @@ WHERE
if err != nil {
return fmt.Errorf("cannot query risk scenario risks: %w", err)
}
results, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[Risk])
if err != nil {
return fmt.Errorf("cannot collect risk scenario risks: %w", err)
}
*rs = results
return nil
}
@@ -177,5 +184,6 @@ WHERE
if err := conn.QueryRow(ctx, q, args).Scan(&count); err != nil {
return 0, fmt.Errorf("cannot count risk scenario risks: %w", err)
}
return count, nil
}

View File

@@ -58,13 +58,16 @@ INSERT INTO risk_assessment_scenario_threats (
"risk_assessment_threat_id": st.RiskAssessmentThreatID,
"created_at": st.CreatedAt,
}
_, err := conn.Exec(ctx, q, args)
if err != nil {
if pgErr, ok := errors.AsType[*pgconn.PgError](err); ok && pgErr.Code == "23505" && pgErr.ConstraintName == "risk_assessment_scenario_threats_pkey" {
return ErrResourceAlreadyExists
}
return fmt.Errorf("cannot insert risk scenario threat: %w", err)
}
return nil
}
@@ -83,6 +86,7 @@ WHERE
}
maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args)
return err
}
@@ -128,11 +132,14 @@ WHERE
if err != nil {
return fmt.Errorf("cannot query risk scenario threats: %w", err)
}
results, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[RiskAssessmentThreat])
if err != nil {
return fmt.Errorf("cannot collect risk scenario threats: %w", err)
}
*ts = results
return nil
}
@@ -168,5 +175,6 @@ WHERE
if err := conn.QueryRow(ctx, q, args).Scan(&count); err != nil {
return 0, fmt.Errorf("cannot count risk scenario threats: %w", err)
}
return count, nil
}

View File

@@ -47,6 +47,7 @@ func (s *RiskAssessmentScope) CursorKey(orderBy RiskAssessmentScopeOrderField) p
case RiskAssessmentScopeOrderFieldName:
return page.CursorKey{ID: s.ID, Value: s.Name}
}
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
}
@@ -58,6 +59,7 @@ func (s *RiskAssessmentScope) AuthorizationAttributes(ctx context.Context, conn
if errors.Is(err, pgx.ErrNoRows) {
return nil, ErrResourceNotFound
}
return nil, fmt.Errorf("cannot query risk assessment scope authorization attributes: %w", err)
}
@@ -95,11 +97,14 @@ WHERE
if err != nil {
return fmt.Errorf("cannot query risk assessment scopes: %w", err)
}
results, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[RiskAssessmentScope])
if err != nil {
return fmt.Errorf("cannot collect risk assessment scopes: %w", err)
}
*ss = results
return nil
}
@@ -127,6 +132,7 @@ WHERE
if err := conn.QueryRow(ctx, q, args).Scan(&count); err != nil {
return 0, fmt.Errorf("cannot count risk assessment scopes: %w", err)
}
return count, nil
}
@@ -149,18 +155,23 @@ LIMIT 1
q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"id": id}
maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot query risk assessment scope: %w", err)
}
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[RiskAssessmentScope])
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound
}
return fmt.Errorf("cannot collect risk assessment scope: %w", err)
}
*s = result
return nil
}
@@ -193,10 +204,12 @@ INSERT INTO risk_assessment_scopes (
"created_at": s.CreatedAt,
"updated_at": s.UpdatedAt,
}
_, err := conn.Exec(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot insert risk assessment scope: %w", err)
}
return nil
}
@@ -213,13 +226,16 @@ WHERE
q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"id": s.ID, "name": s.Name, "updated_at": s.UpdatedAt}
maps.Copy(args, scope.SQLArguments())
result, err := conn.Exec(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot update risk assessment scope: %w", err)
}
if result.RowsAffected() == 0 {
return ErrResourceNotFound
}
return nil
}
@@ -234,5 +250,6 @@ WHERE
args := pgx.StrictNamedArgs{"id": id}
maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args)
return err
}

View File

@@ -50,6 +50,7 @@ func (t *RiskAssessmentThreat) CursorKey(orderBy RiskAssessmentThreatOrderField)
case RiskAssessmentThreatOrderFieldName:
return page.CursorKey{ID: t.ID, Value: t.Name}
}
panic(fmt.Sprintf("unsupported order by: %s", orderBy))
}
@@ -61,6 +62,7 @@ func (t *RiskAssessmentThreat) AuthorizationAttributes(ctx context.Context, conn
if errors.Is(err, pgx.ErrNoRows) {
return nil, ErrResourceNotFound
}
return nil, fmt.Errorf("cannot query risk assessment threat authorization attributes: %w", err)
}
@@ -100,11 +102,14 @@ WHERE
if err != nil {
return fmt.Errorf("cannot query risk threats: %w", err)
}
results, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[RiskAssessmentThreat])
if err != nil {
return fmt.Errorf("cannot collect risk threats: %w", err)
}
*ts = results
return nil
}
@@ -140,11 +145,14 @@ ORDER BY
if err != nil {
return fmt.Errorf("cannot query risk threats: %w", err)
}
results, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[RiskAssessmentThreat])
if err != nil {
return fmt.Errorf("cannot collect risk threats: %w", err)
}
*ts = results
return nil
}
@@ -172,6 +180,7 @@ WHERE
if err := conn.QueryRow(ctx, q, args).Scan(&count); err != nil {
return 0, fmt.Errorf("cannot count risk threats: %w", err)
}
return count, nil
}
@@ -196,18 +205,23 @@ LIMIT 1;
q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"id": id}
maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot query risk threat: %w", err)
}
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[RiskAssessmentThreat])
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return ErrResourceNotFound
}
return fmt.Errorf("cannot collect risk threat: %w", err)
}
*t = result
return nil
}
@@ -246,13 +260,16 @@ INSERT INTO risk_assessment_threats (
"created_at": t.CreatedAt,
"updated_at": t.UpdatedAt,
}
_, err := conn.Exec(ctx, q, args)
if err != nil {
if pgErr, ok := errors.AsType[*pgconn.PgError](err); ok && pgErr.Code == "23505" && pgErr.ConstraintName == "risk_assessment_threats_unique_name" {
return ErrResourceAlreadyExists
}
return fmt.Errorf("cannot insert risk threat: %w", err)
}
return nil
}
@@ -277,13 +294,16 @@ WHERE
"updated_at": t.UpdatedAt,
}
maps.Copy(args, scope.SQLArguments())
result, err := conn.Exec(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot update risk threat: %w", err)
}
if result.RowsAffected() == 0 {
return ErrResourceNotFound
}
return nil
}
@@ -298,5 +318,6 @@ WHERE
args := pgx.StrictNamedArgs{"id": id}
maps.Copy(args, scope.SQLArguments())
_, err := conn.Exec(ctx, q, args)
return err
}