Skip to content

Commit

Permalink
infra/linters: Replace spellcheck with typos
Browse files Browse the repository at this point in the history
Use typos to find misspelled words since it does not require extensive
wordlists and it is easier to configurate. The trade-off is that it will
not complain about uncommon typos since it will assume they are
technical terms.
Overall it should be a lot easier to maintain than spellcheck.

Signed-off-by: Alex Apostolescu <[email protected]>
  • Loading branch information
Alex-deVis committed Dec 29, 2024
1 parent 85302e1 commit ad663e0
Show file tree
Hide file tree
Showing 33 changed files with 1,665 additions and 1,629 deletions.
3 changes: 3 additions & 0 deletions .checkpatch.ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore directories containing third-party files
chapters/compute/synchronization/drills/tasks/threadsafe-data-struct/support
content/assignments/async-web-server/src/http-parser
19 changes: 19 additions & 0 deletions .github/.typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[default]
# ```(console)?[\\s\\S]+?``` -> Ignore fenced sequences
# -\\w+|--\\w+ -> Ignore command flags
extend-ignore-re = ["```(console)?[\\s\\S]+?```", "-\\w+|--\\w+"]
[files]
extend-exclude = [
"*.svg",
"*.drawio",
"ssh_key",
"ssh_key.pub",
"content/assignments/async-web-server/src/http-parser/samples/Makefile", # Windows compile flags
# Third-party files
"chapters/compute/processes-threads-apache2/guides/apache2/support/httpd.conf",
"chapters/compute/processes-threads-apache2/drills/tasks/apache2/support/httpd.conf"
]
[default.extend-words]
# word1 = "word2" to correct word1 to word2
# word3 = "word3" to consider word3 a valid word
VAS = "VAS"
10 changes: 4 additions & 6 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ jobs:
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

spellcheck:
name: Spellcheck
typos:
name: Typos
runs-on: ubuntu-latest
steps:
- name: Spellcheck
uses: open-education-hub/actions/spellcheck@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Typos
uses: open-education-hub/actions/typos@main
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": false
}
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,16 @@ clean: stop_bash

cleanall: clean
-docker inspect --type=image $(IMAGE_NAME) > /dev/null 2>&1 && docker image rm $(IMAGE_NAME)

# Linters
.PHONY: lint typos
lint: typos

typos:
@echo "Running crate-ci/typos"
@# Replace ghcr.io/alex-devis/typos:1.28.4 with ghcr.io/crate-ci/typos:latest
@# once https://github.com/crate-ci/typos/pull/1183 or equivalent is merged.
@docker run --rm -v $(PWD):/data -w /data \
ghcr.io/alex-devis/typos:latest \
--config .github/.typos.toml . \
--exclude spellcheck # Do not validate spellcheck wordlist
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main(void)

time = 1000 * (stop.tv_sec - start.tv_sec) + (stop.tv_usec - start.tv_usec) / 1000;

printf("Array sum is %ld\nTime spent: %lu miliseconds\n", result, time);
printf("Array sum is %ld\nTime spent: %lu milliseconds\n", result, time);

free(array);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void queue_destroy(QUEUE *queue);
size_t queue_size(const QUEUE *queue);


/* Add elem to the end of queue. Returns 0 on succes and non-zero on
/* Add elem to the end of queue. Returns 0 on success and non-zero on
* failure.
*/
int queue_enqueue(QUEUE *queue, TCB *elem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void queue_destroy(QUEUE *queue);
size_t queue_size(const QUEUE *queue);


/* Add elem to the end of queue. Returns 0 on succes and non-zero on
/* Add elem to the end of queue. Returns 0 on success and non-zero on
* failure.
*/
int queue_enqueue(QUEUE *queue, TCB *elem);
Expand Down
2 changes: 1 addition & 1 deletion chapters/compute/scheduling/guides/libult/solution/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void queue_destroy(QUEUE *queue);
size_t queue_size(const QUEUE *queue);


/* Add elem to the end of queue. Returns 0 on succes and non-zero on
/* Add elem to the end of queue. Returns 0 on success and non-zero on
* failure.
*/
int queue_enqueue(QUEUE *queue, TCB *elem);
Expand Down
2 changes: 1 addition & 1 deletion chapters/compute/scheduling/guides/libult/support/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void queue_destroy(QUEUE *queue);
size_t queue_size(const QUEUE *queue);


/* Add elem to the end of queue. Returns 0 on succes and non-zero on
/* Add elem to the end of queue. Returns 0 on success and non-zero on
* failure.
*/
int queue_enqueue(QUEUE *queue, TCB *elem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void incrementVar()
// `atomicOp` is a template function. It can perform any simple
// operation, such as `+=`, &= or `-=`, atomically. The operations is
// given to the function as a template argument using the following
// construction: !"+=". The values in parantheses are the operands
// construction: !"+=". The values in parentheses are the operands
// of the atomic operation.
atomicOp!"+="(var, 1);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,110 +1,110 @@
/******************************************/
/* */
/* Alexander Agdgomlishvili */
/* */
/* [email protected] */
/* */
/******************************************/


/**
* BSD 2-Clause License
*
* Copyright (c) 2020, Alexander Agdgomlishvili
* [email protected]
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/* Github link: https://github.com/AlexanderAgd/CLIST */

#ifndef CLIST_H
#define CLIST_H

#ifdef __cplusplus
extern "C" {
#endif

typedef struct CList
{
void * (* add) (struct CList *l, void *o); /* Add object to the end of a list */
void * (* insert) (struct CList *l, void *o, int n); /* Insert object at position 'n' */
void * (* replace) (struct CList *l, void *o, int n); /* Replace object at position 'n' */
void (* remove) (struct CList *l, int n); /* Remove object at position 'n' */
void * (* at) (struct CList *l, int n); /* Get object at position 'n' */
int (* realloc) (struct CList *l, int n); /* Reallocate list to 'size' items */
int (* count) (struct CList *l); /* Get list size in items */
void * (* firstMatch) (struct CList *l, const void *o, size_t shift, size_t size, int string);
/* Returns object with first match of string or byte compare */
void * (* lastMatch) (struct CList *l, const void *o, size_t shift, size_t size, int string);
/* Returns object with last match of string or byte compare */
int (* index) (struct CList *l); /* Get index of previos search match */
int (* swap) (struct CList *l, int a, int b); /* Swap, replace two items with index a b */
int (* allocSize) (struct CList *l); /* Get allocated size in items */
size_t (* itemSize) (struct CList *l); /* Get item size in bytes */
void (* print) (struct CList *l, size_t shift, int n, const char *type); /* Print list data */
void (* clear) (struct CList *l); /* Clear list */
void (* free) (struct CList *l); /* Destroy struct CList and all data */
void *priv; /* NOT FOR USE, private data */
} CList;

CList *CList_init(size_t objSize); /* Set list object size in bytes */

/* void *add(struct CList *l, void *o);
Returns pointer to added object; Returns NULL if failed.
void *insert(struct CList *l, void *o, int n);
Returns pointer to inserted object; Returns NULL if failed.
void *replace(struct CList *l, void *o, int n);
Returns pointer to replaced object; Returns NULL if failed.
void *at(struct CList *l, int n);
Returns pointer to object at index n;
int realloc(struct CList *l, int n);
Return 1 when success. Returns 0 if failed.
void *firstMatch(struct CList *l, const void *o, size_t shift, size_t size, int string);
Returns pointer to list item when first match found. Straight scanning, from 0 to list end.
Returns NULL if search failed.
void *lastMatch(struct CList *l, const void *o, size_t shift, size_t size, int string);
Returns pointer to list item when first match found. Reverse scanning, from list end to 0.
Returns NULL if search failed.
int index(struct CList *l);
Returns index of last search firstMatch or lastMatch. Returns -1 if search failed.
void print(struct CList *l, size_t shift, int n, const char *type);
Prints data of "int n" list items with offset "size_t shift" and type "const char *type".
Supported types: char, short, int, long, uintptr_t, size_t, double, string.
If type is NULL just pointers data will be printed.
*/

#ifdef __cplusplus
}
#endif

#endif /* CLIST_H */
/******************************************/
/* */
/* Alexander Agdgomlishvili */
/* */
/* [email protected] */
/* */
/******************************************/


/**
* BSD 2-Clause License
*
* Copyright (c) 2020, Alexander Agdgomlishvili
* [email protected]
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/* Github link: https://github.com/AlexanderAgd/CLIST */

#ifndef CLIST_H
#define CLIST_H

#ifdef __cplusplus
extern "C" {
#endif

typedef struct CList
{
void * (* add) (struct CList *l, void *o); /* Add object to the end of a list */
void * (* insert) (struct CList *l, void *o, int n); /* Insert object at position 'n' */
void * (* replace) (struct CList *l, void *o, int n); /* Replace object at position 'n' */
void (* remove) (struct CList *l, int n); /* Remove object at position 'n' */
void * (* at) (struct CList *l, int n); /* Get object at position 'n' */
int (* realloc) (struct CList *l, int n); /* Reallocate list to 'size' items */
int (* count) (struct CList *l); /* Get list size in items */
void * (* firstMatch) (struct CList *l, const void *o, size_t shift, size_t size, int string);
/* Returns object with first match of string or byte compare */
void * (* lastMatch) (struct CList *l, const void *o, size_t shift, size_t size, int string);
/* Returns object with last match of string or byte compare */
int (* index) (struct CList *l); /* Get index of previous search match */
int (* swap) (struct CList *l, int a, int b); /* Swap, replace two items with index a b */
int (* allocSize) (struct CList *l); /* Get allocated size in items */
size_t (* itemSize) (struct CList *l); /* Get item size in bytes */
void (* print) (struct CList *l, size_t shift, int n, const char *type); /* Print list data */
void (* clear) (struct CList *l); /* Clear list */
void (* free) (struct CList *l); /* Destroy struct CList and all data */
void *priv; /* NOT FOR USE, private data */
} CList;

CList *CList_init(size_t objSize); /* Set list object size in bytes */

/* void *add(struct CList *l, void *o);
Returns pointer to added object; Returns NULL if failed.
void *insert(struct CList *l, void *o, int n);
Returns pointer to inserted object; Returns NULL if failed.
void *replace(struct CList *l, void *o, int n);
Returns pointer to replaced object; Returns NULL if failed.
void *at(struct CList *l, int n);
Returns pointer to object at index n;
int realloc(struct CList *l, int n);
Return 1 when success. Returns 0 if failed.
void *firstMatch(struct CList *l, const void *o, size_t shift, size_t size, int string);
Returns pointer to list item when first match found. Straight scanning, from 0 to list end.
Returns NULL if search failed.
void *lastMatch(struct CList *l, const void *o, size_t shift, size_t size, int string);
Returns pointer to list item when first match found. Reverse scanning, from list end to 0.
Returns NULL if search failed.
int index(struct CList *l);
Returns index of last search firstMatch or lastMatch. Returns -1 if search failed.
void print(struct CList *l, size_t shift, int n, const char *type);
Prints data of "int n" list items with offset "size_t shift" and type "const char *type".
Supported types: char, short, int, long, uintptr_t, size_t, double, string.
If type is NULL just pointers data will be printed.
*/

#ifdef __cplusplus
}
#endif

#endif /* CLIST_H */
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ int main(void)

/******************************************************* POINTERS LIST */

/* If we want create list of objects located in diffent places of memory, */
/* If we want create list of objects located in different places of memory, */
/* let create pointers list or in our case "uintptr_t" address list */

printf("Size of 'uintptr_t' = %zu bytes\n", sizeof(uintptr_t));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void mutex_unlock(struct mutex *m)
* Prevents overhead from busy-waiting
* Threads move to WAITING state while waiting for the lock
* Introduces overhead from context switch
* Releasing a mutex held by another thread is [**undefinded behaviour**](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_lock.html)
* Releasing a mutex held by another thread is [**undefined behaviour**](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_lock.html)
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ void main(string[] args)

for (size_t i = 0; i < numProcesses; ++i)
{
size_t elemsPerThred = cast(size_t) ceil(
size_t elemsPerThread = cast(size_t) ceil(
(cast(double) ARR_LEN) / numProcesses);
size_t start = i * elemsPerThred;
size_t end = min(ARR_LEN, (i + 1) * elemsPerThred);
size_t start = i * elemsPerThread;
size_t end = min(ARR_LEN, (i + 1) * elemsPerThread);

// Spawn another process with the current one as its parent.
children[i] = fork();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main(void)

time = 1000 * (stop.tv_sec - start.tv_sec) + (stop.tv_usec - start.tv_usec) / 1000;

printf("Array sum is %ld\nTime spent: %lu miliseconds\n", result, time);
printf("Array sum is %ld\nTime spent: %lu milliseconds\n", result, time);

free(array);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main(void)

time = 1000 * (stop.tv_sec - start.tv_sec) + (stop.tv_usec - start.tv_usec) / 1000;

printf("Array sum is %ld\nTime spent: %lu miliseconds\n", result, time);
printf("Array sum is %ld\nTime spent: %lu milliseconds\n", result, time);

free(array);

Expand Down
Loading

0 comments on commit ad663e0

Please sign in to comment.