-
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
ci(lint): fix linter for multi-module repo #13
Conversation
WalkthroughThe recent changes involve enhancements and adjustments across various files within the project. These updates primarily focus on refining import statements and formatting in different Go files to maintain consistency and improve readability without altering the core functionality significantly. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 0
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (1)
- .github/workflows/lint.yml (2 hunks)
Additional comments not posted (2)
.github/workflows/lint.yml (2)
14-16
: The addition of thestrategy
block with amatrix
is a good approach to ensuregolangci-lint
checks all specified modules. Please verify that all relevant modules are included.
29-29
: The update to dynamically set theworking-directory
is crucial for the effectiveness of the linting process across different modules. This change ensures thatgolangci-lint
runs in the context of each specified module.
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.
Actionable comments posted: 0
Actionable comments outside the diff hunks (2)
functions/src/handlers/lookup/main.go (1)
Line range hint
49-49
: Use parameterized queries to prevent SQL injection.- query := fmt.Sprintf(`SELECT * FROM airports WHERE local_code = "%s"`, html.EscapeString(lc)) + query := `SELECT * FROM airports WHERE local_code = ?` + data, err := f.tarmac.SQL.Query(query, html.EscapeString(lc))Direct string concatenation in SQL queries can lead to SQL injection vulnerabilities. Use parameterized queries instead to enhance security.
functions/src/data/load/main.go (1)
Line range hint
52-52
: Use parameterized queries to enhance security.- query := fmt.Sprintf(`INSERT INTO airports (...) VALUES (...) ON DUPLICATE KEY UPDATE ...;`, html.EscapeString(airport.LocalCode), ...) + query := `INSERT INTO airports (...) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE ...;` + _, err := f.tarmac.SQL.Query(query, html.EscapeString(airport.LocalCode), ...)Direct string concatenation in SQL queries can lead to SQL injection vulnerabilities. Use parameterized queries instead to enhance security.
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (7)
- 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/main.go (1 hunks)
- pkg/airport/airport.go (1 hunks)
- pkg/airport/parsers/csv/csv.go (1 hunks)
- pkg/airport/parsers/csv/csv_test.go (1 hunks)
Files skipped from review due to trivial changes (4)
- functions/src/data/fetch/main.go
- functions/src/data/init/main.go
- pkg/airport/parsers/csv/csv.go
- pkg/airport/parsers/csv/csv_test.go
Additional comments not posted (7)
functions/src/handlers/lookup/main.go (4)
11-11
: Consider grouping standard library imports together.It's a common Go convention to group imports into three sections: standard library, third-party packages, and internal packages. This enhances readability and maintainability. You might want to group the
"html"
import with other standard library imports.
Line range hint
39-41
: Ensure proper error handling for missinglocal_code
.Returning both an error and a non-nil response might lead to ambiguous behavior. Consider standardizing the error handling approach to either return an error or a valid response, but not both.
Line range hint
73-73
: Consider caching the response before returning.You're adding the response to the cache after creating the JSON response. It might be more efficient to cache the data as soon as it's retrieved from the database, before processing it into the final JSON format. This could save processing time in future requests.
Line range hint
85-93
: Optimize base64 decoding indecodeData
.You're decoding base64 strings inside a loop. If the decoding process is CPU-intensive and the data set is large, consider parallelizing this operation or using a more efficient method to handle the decoding.
pkg/airport/airport.go (1)
5-5
: Import ofemoji
package added.The addition of the
emoji
package import is consistent with the usage in thesetTypeEmoji
andsetCountryFlag
functions. This change enhances the functionality by allowing the representation of airport types and countries with emojis.functions/src/data/load/main.go (2)
13-13
: Consider grouping standard library imports together.Similar to the previous file, it's a good practice in Go to group imports by their types: standard library, third-party packages, and internal packages. This enhances readability and maintainability. Grouping the
"html"
import with other standard library imports would align with this convention.
Line range hint
70-70
: Consider handling database update failures more gracefully.When a database update fails, logging the error is a good practice, but it might also be beneficial to implement a retry mechanism or log the specific data causing the failure for easier debugging and recovery.
Currently, golangci-lint is not checking sub-directories.
Summary by CodeRabbit