-
Notifications
You must be signed in to change notification settings - Fork 2
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
Refactoring project structure #9
Conversation
WalkthroughThe project has undergone a build process overhaul, with a restructured output directory and the addition of a testing suite for the lookup function. New functionalities for fetching and loading data have been implemented, and the lookup handler has been updated with a new entry point function and descriptive comments. Changes
TipsChat with CodeRabbit Bot (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9 +/- ##
=======================================
Coverage 92.92% 92.92%
=======================================
Files 2 2
Lines 99 99
=======================================
Hits 92 92
Misses 5 5
Partials 2 2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 7
Configuration used: CodeRabbit UI
Files ignored due to filter (6)
- config/tarmac.json
- functions/src/data/init/go.mod
- functions/src/data/init/go.sum
- functions/src/handlers/lookup/go.mod
- functions/src/handlers/lookup/go.sum
- functions/src/init/go.mod
Files selected for processing (6)
- Makefile (1 hunks)
- functions/src/data/fetch/main.go (1 hunks)
- functions/src/data/init/main.go (1 hunks)
- functions/src/data/load/main.go (1 hunks)
- functions/src/handlers/lookup/Makefile (1 hunks)
- functions/src/handlers/lookup/main.go (2 hunks)
Files skipped from review due to trivial changes (3)
- functions/src/data/init/main.go
- functions/src/handlers/lookup/Makefile
- functions/src/handlers/lookup/main.go
Additional comments: 2
Makefile (1)
- 1-25:
The refactoring of thebuild
target and the addition of thetests
target are aligned with the summary of changes. Thedocker-compose
target is unchanged as expected.functions/src/data/load/main.go (1)
- 1-7:
The comment block at the top of the file is clear and informative.
.PHONY: tests | ||
tests: | ||
## Run tests | ||
mkdir -p coverage | ||
go test -v -race -covermode=atomic -coverprofile=coverage/coverage.out ./... | ||
go tool cover -html=coverage/coverage.out -o coverage/coverage.html | ||
## Run tests for the lookup function | ||
$(MAKE) -C functions/src/handlers/lookup tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mkdir
command for the coverage
directory should be checked to avoid unnecessary directory creation if it already exists.
- mkdir -p coverage
+ [ -d coverage ] || mkdir -p coverage
Commitable suggestion
❗ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
.PHONY: tests | |
tests: | |
## Run tests | |
mkdir -p coverage | |
go test -v -race -covermode=atomic -coverprofile=coverage/coverage.out ./... | |
go tool cover -html=coverage/coverage.out -o coverage/coverage.html | |
## Run tests for the lookup function | |
$(MAKE) -C functions/src/handlers/lookup tests | |
.PHONY: tests | |
tests: | |
## Run tests | |
[ -d coverage ] || mkdir -p coverage | |
go test -v -race -covermode=atomic -coverprofile=coverage/coverage.out ./... | |
go tool cover -html=coverage/coverage.out -o coverage/coverage.html | |
## Run tests for the lookup function | |
$(MAKE) -C functions/src/handlers/lookup tests |
/* | ||
This function fetches airport data from a remote CSV file via HTTP and returns it to the application. It is designed | ||
for reuse throughout the application. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment block provides a good overview of the purpose of the fetch
function. However, it should also mention the expected format of the data (CSV) and any assumptions made (e.g., the structure of the CSV file, if any).
/* | ||
This function fetches airport data from a remote CSV file via HTTP and returns it to the application. It is designed | ||
for reuse throughout the application. | ||
*/ | ||
package main | ||
|
||
import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This review was outside of the patch, but no patch was found that overlapped with it. Original lines [15-15]
The Function
struct is missing documentation. It's important to explain the purpose of each member, especially tarmac
, which seems to be central to the operation of this function.
Note: This review was outside of the patch, but no patch was found that overlapped with it. Original lines [24-24]
The error message "failed to get airports.csv" is repeated. It would be better to define this as a constant or to use a more descriptive message in each case to differentiate between the error of the HTTP GET request and the error of an unsatisfactory status code.
Note: This review was outside of the patch, but no patch was found that overlapped with it. Original lines [31-31]
The check for rsp.StatusCode >= 299
is unconventional. Typically, the check is for rsp.StatusCode >= 400
to catch client and server errors. If the intention is to catch redirects as well, this should be explicitly documented.
Note: This review was outside of the patch, but no patch was found that overlapped with it. Original lines [37-45]
Error handling is missing if the SDK initialization fails. The application should log the error and exit with a non-zero status code to indicate failure.
if err != nil {
+ log.Fatalf("Failed to initialize Tarmac SDK: %v", err)
- return
}
|
||
This function is called multiple times throughout the application. It's called by an "init" function and also set | ||
as a scheduled task by itself. | ||
*/ | ||
package main | ||
|
||
import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Syntax error in the import block.
import (
+ )
Commitable suggestion
❗ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
import ( | |
import ( | |
) |
This PR refactors a bit of the project structure to make things a bit easier to find and a bit more organized.
Summary by CodeRabbit
New Features
Documentation
Refactor
Tests
tests
target in the Makefile to facilitate running Go tests with additional flags.