Skip to content

CI: add typos-action to GHA #1679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: development
Choose a base branch
from
12 changes: 12 additions & 0 deletions .github/workflows/typos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Typos Check
on:
push:
pull_request:
jobs:
typos:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: typos-action
uses: crate-ci/typos@v1.31.2
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
* (Optional) If you want to discuss your implementation with the users of GoFr, use the GitHub discussions of this repo.
* Configure your editor to use goimport and golangci-lint on file changes. Any code which is not formatted using these
tools, will fail on the pipeline.
<!-- spellchecker:off "favour" have to be ignored here -->
* We follow **American English** conventions in this project (e.g., *"favor"* instead of *"favour"*). Please keep this consistent across all code comments, documentation, etc.
<!-- spellchecker:on -->
* All code contributions should have associated tests and all new line additions should be covered in those testcases.
No PR should ever decrease the overall code coverage.
* Once your code changes are done along with the testcases, submit a PR to development branch. Please note that all PRs
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced-guide/handling-data-migrations/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func All() map[int64]migration.Migrate {

Migrations run in ascending order of keys in this map.

### Initialisation from main.go
### Initialization from main.go

```go
package main
Expand Down
4 changes: 2 additions & 2 deletions docs/advanced-guide/handling-file/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ GoFr simplifies the complexity of working with different file stores by offering

## USAGE

By default, local file-store is initialised and user can access it from the context.
By default, local file-store is initialized and user can access it from the context.

GoFr also supports FTP/SFTP file-store. Developers can also connect and use their AWS S3 bucket as a file-store. The file-store can be initialised as follows:
GoFr also supports FTP/SFTP file-store. Developers can also connect and use their AWS S3 bucket as a file-store. The file-store can be initialized as follows:

### FTP file-store
```go
Expand Down
4 changes: 2 additions & 2 deletions docs/advanced-guide/http-authentication/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ GoFr offers two ways to implement API Keys authentication.
package main

func main() {
// initialise gofr object
// initialize gofr object
app := gofr.New()

app.EnableAPIKeyAuth("9221e451-451f-4cd6-a23d-2b2d3adea9cf", "0d98ecfe-4677-48aa-b463-d43505766915")
Expand All @@ -109,7 +109,7 @@ func apiKeyValidator(c *container.Container, apiKey string) bool {
}

func main() {
// initialise gofr object
// initialize gofr object
app := gofr.New()

app.EnableAPIKeyAuthWithValidator(apiKeyValidator)
Expand Down
12 changes: 6 additions & 6 deletions docs/advanced-guide/publishing-custom-metrics/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

func main() {
// initialise gofr object
// initialize gofr object
app := gofr.New()

app.Metrics().NewCounter("transaction_success", "used to track the count of successful transactions")
Expand Down Expand Up @@ -58,7 +58,7 @@ import (
)

func main() {
// initialise gofr object
// initialize gofr object
app := gofr.New()

app.Metrics().NewUpDownCounter("total_credit_day_sale", "used to track the total credit sales in a day")
Expand Down Expand Up @@ -88,7 +88,7 @@ import (
)

func main() {
// initialise gofr object
// initialize gofr object
app := gofr.New()

app.Metrics().NewHistogram("transaction_time", "used to track the time taken by a transaction",
Expand Down Expand Up @@ -124,7 +124,7 @@ import (
)

func main() {
// initialise gofr object
// initialize gofr object
app := gofr.New()

app.Metrics().NewGauge("product_stock", "used to track the number of products in stock")
Expand Down Expand Up @@ -178,7 +178,7 @@ import (
)

func main() {
// Initialise gofr object
// Initialize gofr object
a := gofr.New()

// Add custom metrics
Expand Down Expand Up @@ -222,7 +222,7 @@ When a registered metrics has to be used 3 key pieces of information are require
- A set of key-value pairs called tags or labels.

A permutation of these key-value values provides the metric cardinality.
Lower the cardinality, faster the query performance and lower the monitoring resource utilisation.
Lower the cardinality, faster the query performance and lower the monitoring resource utilization.
```

> #### Check out the example on how to publish custom metrics in GoFr: [Visit GitHub](https://github.com/gofr-dev/gofr/blob/main/examples/using-custom-metrics/main.go)
2 changes: 1 addition & 1 deletion docs/advanced-guide/using-publisher-subscriber/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ that are specific for the type of message broker user wants to use.
---

- `PUBSUB_BROKER`
- Address to connect to kafka broker. Multiple brokers can be added as comma seperated values.
- Address to connect to kafka broker. Multiple brokers can be added as comma separated values.
- `+`
-
- `localhost:9092` or `localhost:8087,localhost:8088,localhost:8089`
Expand Down
2 changes: 1 addition & 1 deletion docs/quick-start/add-rest-handlers/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
GoFr simplifies the process of implementing CRUD (Create, Read, Update, Delete) operations by enabling the automatic generation of handlers directly from Go structs.
This feature eliminates the need for writing repetitive boilerplate code, allowing developers to focus on application logic.

## Default Behaviour
## Default Behavior

If the custom handlers ain't implemented on the struct, GoFr provides default handlers for each CRUD operation. These handlers handle basic database interactions:

Expand Down
2 changes: 1 addition & 1 deletion docs/quick-start/connecting-mysql/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type Customer struct {
}

func main() {
// initialise gofr object
// initialize gofr object
app := gofr.New()

app.GET("/redis", func(ctx *gofr.Context) (any, error) {
Expand Down
2 changes: 1 addition & 1 deletion docs/quick-start/introduction/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ package main
import "gofr.dev/pkg/gofr"

func main() {
// initialise gofr object
// initialize gofr object
app := gofr.New()

// register route greet
Expand Down
2 changes: 1 addition & 1 deletion docs/references/testing/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func Add(ctx *gofr.Context) (any, error) {
}

func main() {
// initialise gofr object
// initialize gofr object
app := gofr.New()

app.POST("/book", Add)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@
"refId": "B"
}
],
"title": "Memory Utilisation",
"title": "Memory Utilization",
"type": "timeseries"
},
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func Test_newContainerSuccessWithLogger(t *testing.T) {

container := NewContainer(cfg)

assert.NotNil(t, container.Logger, "TEST, Failed.\nlogger initialisation")
assert.NotNil(t, container.Logger, "TEST, Failed.\nlogger initialization")
}

func Test_newContainerDBInitializationFail(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/gofr/container/mock_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewMockContainer(t *testing.T, options ...options) (*Container, *Mocks) {
ctrl := gomock.NewController(t)

mockDB, sqlMock, _ := sql.NewSQLMocks(t)
// initialisation of expectations
// initialization of expectations
expectation := expectedQuery{}

sqlMockWrapper := &mockSQL{sqlMock, &expectation}
Expand Down Expand Up @@ -132,7 +132,7 @@ func NewMockContainer(t *testing.T, options ...options) (*Container, *Mocks) {
Metrics: mockMetrics,
}

// TODO: Remove this expectation from mock container (previous generalisation) to the actual tests where their expectations are being set.
// TODO: Remove this expectation from mock container (previous generalization) to the actual tests where their expectations are being set.
mockMetrics.EXPECT().RecordHistogram(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(),
gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()

Expand Down
6 changes: 3 additions & 3 deletions pkg/gofr/datasource/cassandra/cassandra_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (c *Client) BatchQueryWithCtx(ctx context.Context, name, stmt string, value

b, ok := c.cassandra.batches[name]
if !ok {
return errBatchNotInitialised
return errBatchNotInitialized
}

b.Query(stmt, values...)
Expand All @@ -47,7 +47,7 @@ func (c *Client) ExecuteBatchWithCtx(ctx context.Context, name string) error {

b, ok := c.cassandra.batches[name]
if !ok {
return errBatchNotInitialised
return errBatchNotInitialized
}

return c.cassandra.session.executeBatch(b)
Expand All @@ -64,7 +64,7 @@ func (c *Client) ExecuteBatchCASWithCtx(ctx context.Context, name string, dest .

b, ok := c.cassandra.batches[name]
if !ok {
return false, errBatchNotInitialised
return false, errBatchNotInitialized
}

return c.cassandra.session.executeBatchCAS(b, dest...)
Expand Down
6 changes: 3 additions & 3 deletions pkg/gofr/datasource/cassandra/cassandra_batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func Test_BatchQuery(t *testing.T) {
}, nil},
{"batch is not initialized", func() {
client.cassandra.batches = nil
}, errBatchNotInitialised},
}, errBatchNotInitialized},
}

for i, tc := range testCases {
Expand Down Expand Up @@ -53,7 +53,7 @@ func Test_ExecuteBatch(t *testing.T) {
}, errMock},
{"batch not initialized", func() {
client.cassandra.batches = nil
}, errBatchNotInitialised},
}, errBatchNotInitialized},
}

for i, tc := range testCases {
Expand Down Expand Up @@ -123,7 +123,7 @@ func Test_ExecuteBatchCAS(t *testing.T) {
}, &mockStructSlice, assert.AnError},
{"failure case: batch not initialized", &mockStructSlice, func() {
client.cassandra.batches = nil
}, &mockStructSlice, errBatchNotInitialised},
}, &mockStructSlice, errBatchNotInitialized},
}

for i, tc := range testCases {
Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/datasource/cassandra/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var (
errDestinationIsNotPointer = errors.New("destination is not pointer")
errUnexpectedMap = errors.New("a map was not expected")
errUnsupportedBatchType = errors.New("batch type not supported")
errBatchNotInitialised = errors.New("batch not initialized")
errBatchNotInitialized = errors.New("batch not initialized")
)

type errUnexpectedPointer struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/gofr/datasource/opentsdb/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ func (c *Client) sendRequest(ctx context.Context, method, url, reqBodyCnt string
if parser == nil {
// Use the default JSON unmarshaller if no custom parser is provided.
if err = json.Unmarshal(jsonBytes, parsedResp); err != nil {
errUnmarshaling := fmt.Errorf("failed to unmarshal response body for %s %s: %w", method, url, err)
errUnmarshalling := fmt.Errorf("failed to unmarshal response body for %s %s: %w", method, url, err)

return errUnmarshaling
return errUnmarshalling
}
} else {
// Use the custom parser if available.
Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/datasource/scylladb/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
var (
errUnsupportedBatchType = errors.New("batch type not supported")
errDestinationIsNotPointer = errors.New("destination is not pointer")
errBatchNotInitialised = errors.New("batch not initialized")
errBatchNotInitialized = errors.New("batch not initialized")
errUnexpectedMap = errors.New("a map was not expected")
)

Expand Down
6 changes: 3 additions & 3 deletions pkg/gofr/datasource/scylladb/scylladb.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func (c *Client) BatchQueryWithCtx(ctx context.Context, name, stmt string, value

b, ok := c.scylla.batches[name]
if !ok {
return errBatchNotInitialised
return errBatchNotInitialized
}

b.Query(stmt, values...)
Expand All @@ -282,7 +282,7 @@ func (c *Client) ExecuteBatchWithCtx(ctx context.Context, name string) error {

b, ok := c.scylla.batches[name]
if !ok {
return errBatchNotInitialised
return errBatchNotInitialized
}

return c.scylla.session.executeBatch(b)
Expand All @@ -305,7 +305,7 @@ func (c *Client) ExecuteBatchCASWithCtx(ctx context.Context, name string, dest .

b, ok := c.scylla.batches[name]
if !ok {
return false, errBatchNotInitialised
return false, errBatchNotInitialized
}

return c.scylla.session.executeBatchCAS(b, dest...)
Expand Down
12 changes: 6 additions & 6 deletions pkg/gofr/datasource/scylladb/scylladb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func Test_BatchQuery(t *testing.T) {
{"batch is not initialized", func() {
mockDeps.mockLogger.EXPECT().Debug(gomock.AssignableToTypeOf(&QueryLog{}))
client.scylla.batches = nil
}, errBatchNotInitialised},
}, errBatchNotInitialized},
}

for i, tc := range testCases {
Expand Down Expand Up @@ -355,7 +355,7 @@ func Test_ExecuteBatchCAS(t *testing.T) {
{"failure case: batch not initialized", &mockStructSlice, func() {
mockDeps.mockLogger.EXPECT().Debug(gomock.AssignableToTypeOf(&QueryLog{}))
client.scylla.batches = nil
}, &mockStructSlice, errBatchNotInitialised},
}, &mockStructSlice, errBatchNotInitialized},
}

for i, tc := range testCases {
Expand Down Expand Up @@ -458,7 +458,7 @@ func TestClient_ExecuteBatchCASWithCtx(t *testing.T) {
mockDeps.mockSession.EXPECT().executeBatch(mockDeps.mockBatch).Return(nil).Times(1)
},
expRes: &mockStructSlice,
expErr: errBatchNotInitialised,
expErr: errBatchNotInitialized,
},
{
desc: "failure case: executeBatch returns error",
Expand All @@ -469,7 +469,7 @@ func TestClient_ExecuteBatchCASWithCtx(t *testing.T) {
mockDeps.mockSession.EXPECT().executeBatch(mockDeps.mockBatch).Return(assert.AnError).Times(1)
},
expRes: &mockStructSlice,
expErr: errBatchNotInitialised,
expErr: errBatchNotInitialized,
},
{
desc: "failure case: batch not initialized",
Expand All @@ -480,7 +480,7 @@ func TestClient_ExecuteBatchCASWithCtx(t *testing.T) {
client.scylla.batches = nil
},
expRes: &mockStructSlice,
expErr: errBatchNotInitialised,
expErr: errBatchNotInitialized,
},
}

Expand Down Expand Up @@ -513,7 +513,7 @@ func Test_ExecuteBatch(t *testing.T) {
{"batch not initialized", func() {
mockDeps.mockLogger.EXPECT().Debug(gomock.AssignableToTypeOf(&QueryLog{}))
client.scylla.batches = nil
}, errBatchNotInitialised},
}, errBatchNotInitialized},
}

for i, tc := range testCases {
Expand Down
4 changes: 2 additions & 2 deletions pkg/gofr/datasource/sql/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (t *Tx) Rollback() error {
}

// Select runs a query with args and binds the result of the query to the data.
// data should ba a point to a slice, struct or any type. Slice will return multiple
// data should be a point to a slice, struct or any type. Slice will return multiple
// objects whereas struct will return a single object.
//
// Example Usages:
Expand Down Expand Up @@ -292,7 +292,7 @@ func (*DB) rowsToStruct(rows *sql.Rows, vo reflect.Value) {
v = vo.Elem()
}

// Map fields and their indexes by normalised name
// Map fields and their indexes by normalized name
fieldNameIndex := map[string]int{}

for i := 0; i < v.Type().NumField(); i++ {
Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/http/middleware/oauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestGetJwtClaims(t *testing.T) {
claims := []byte(`{"aud":"stage.kops.dev","iat":1257894000,"orig":"GOOGLE",` +
`"picture":"https://lh3.googleusercontent.com/a/ACg8ocKJ5DDA4zruzFlsQ9KvL` +
`jHDtbOT_hpVz0hEO8jSl2m7Myk=s96-c","sub":"rakshit.singh@zopsmart.com","sub-id"` +
`:"a6573e1d-abea-4863-acdb-6cf3626a4414","typ":"refresh_token"}`)
`:"a6573e1d-abea-4863-acdb-6cf3626a4414","type":"refresh_token"}`)

router := mux.NewRouter()
router.HandleFunc("/test", func(w http.ResponseWriter, r *http.Request) {
Expand Down
Loading