Skip to content

Commit 635217d

Browse files
Copilotadriens
andcommitted
Apply code quality fixes: update comment, rename ApiUrl to APIUrl, extract URL constant
Co-authored-by: adriens <[email protected]>
1 parent fbeca19 commit 635217d

File tree

11 files changed

+18
-16
lines changed

11 files changed

+18
-16
lines changed

cmd/category.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ geol category cloud`,
4343
log.Fatal().Msgf("Category '%s' not found in cache", category)
4444
}
4545

46-
url := utilities.ApiUrl + "categories/" + category
46+
url := utilities.APIUrl + "categories/" + category
4747
resp, err := http.Get(url)
4848
if err != nil {
4949
log.Fatal().Err(err).Msgf("Error requesting category '%s'", category)

cmd/check.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func lookupEolDate(idEol, version string) (string, bool, string) {
191191
}
192192

193193
if len(prod) > 0 {
194-
url := utilities.ApiUrl + "products/" + prod + "/releases/" + version
194+
url := utilities.APIUrl + "products/" + prod + "/releases/" + version
195195
resp, err := http.Get(url)
196196
if err != nil {
197197
log.Error().Err(err).Msgf("Error requesting %s", prod)
@@ -223,7 +223,7 @@ func lookupEolDate(idEol, version string) (string, bool, string) {
223223
os.Exit(1)
224224
}
225225

226-
url = utilities.ApiUrl + "products/" + prod
226+
url = utilities.APIUrl + "products/" + prod
227227
resp, err = http.Get(url)
228228
if err != nil {
229229
log.Error().Err(err).Msgf("Error requesting %s", prod)

cmd/exports/duckdb.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func fetchAllProductData(cmd *cobra.Command) (*allProductsData, error) {
148148
go func() {
149149
for productName := range products.Products {
150150
// Fetch basic product info
151-
url := utilities.ApiUrl + "products/" + productName
151+
url := utilities.APIUrl + "products/" + productName
152152
resp, err := http.Get(url)
153153
if err != nil {
154154
log.Warn().Err(err).Msgf("Error requesting %s, skipping", productName)
@@ -230,7 +230,7 @@ func fetchAllProductData(cmd *cobra.Command) (*allProductsData, error) {
230230
// fetchAllCategories retrieves all categories from the API
231231
func fetchAllCategories() (map[string]utilities.Category, error) {
232232
// Fetch categories from API
233-
resp, err := http.Get(utilities.ApiUrl + "categories")
233+
resp, err := http.Get(utilities.APIUrl + "categories")
234234
if err != nil {
235235
log.Error().Err(err).Msg("Error fetching categories")
236236
return nil, err
@@ -262,7 +262,7 @@ func fetchAllCategories() (map[string]utilities.Category, error) {
262262
// fetchAllTags retrieves all tags from the API
263263
func fetchAllTags() (map[string]utilities.Tag, error) {
264264
// Fetch tags from API
265-
resp, err := http.Get(utilities.ApiUrl + "tags")
265+
resp, err := http.Get(utilities.APIUrl + "tags")
266266
if err != nil {
267267
log.Error().Err(err).Msg("Error fetching tags")
268268
return nil, err

cmd/product/describe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ var describeCmd = &cobra.Command{
125125
os.Exit(1)
126126
}
127127

128-
url := utilities.ApiUrl + "products/" + mainName
128+
url := utilities.APIUrl + "products/" + mainName
129129
resp, err = http.Get(url)
130130
if err != nil {
131131
log.Error().Err(err).Msgf("Error requesting %s", mainName)

cmd/product/extended.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func renderProductTable(prod ProductReleases, numberFlag int, mdFlag bool, isFir
279279

280280
// FetchProductData retrieves product release data from the API
281281
func FetchProductData(productName string) (ProductReleases, error) {
282-
url := utilities.ApiUrl + "products/" + productName
282+
url := utilities.APIUrl + "products/" + productName
283283
resp, err := http.Get(url)
284284
if err != nil {
285285
return ProductReleases{}, fmt.Errorf("error requesting %s: %w", productName, err)

cmd/product/product.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ geol product describe nodejs`,
7373
}
7474

7575
// API request for this product
76-
url := utilities.ApiUrl + "products/" + prod
76+
url := utilities.APIUrl + "products/" + prod
7777
resp, err := http.Get(url)
7878
if err != nil {
7979
log.Fatal().Err(err).Msgf("Error requesting %s", prod)

cmd/tag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ geol tag canonical`,
4848
log.Fatal().Msgf("Tag '%s' not found in cache", tag)
4949
}
5050

51-
url := utilities.ApiUrl + "tags/" + tag
51+
url := utilities.APIUrl + "tags/" + tag
5252
resp, err := http.Get(url)
5353
if err != nil {
5454
log.Fatal().Err(err).Msgf("Error requesting tag '%s'", tag)

utilities/categoriesTools.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func FetchAndSaveCategories(cmd *cobra.Command) error {
3434
return err
3535
}
3636
// HTTP GET request (extracted)
37-
resp, err := GetAPIResponse(ApiUrl + "categories")
37+
resp, err := GetAPIResponse(APIUrl + "categories")
3838
if err != nil {
3939
log.Error().Err(err).Msg("Error during HTTP request")
4040
return err

utilities/productTools.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func FetchAndSaveProducts(cmd *cobra.Command) error {
6161
}
6262

6363
// HTTP GET request (extracted)
64-
resp, err := GetAPIResponse(ApiUrl + "products")
64+
resp, err := GetAPIResponse(APIUrl + "products")
6565
if err != nil {
6666
log.Error().Err(err).Msg("Error during HTTP request")
6767
return err

utilities/tagTools.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"github.com/spf13/cobra"
1111
)
1212

13+
const tagBaseURL = "https://endoflife.date/api/v1/tags/"
14+
1315
type Tag struct {
1416
Name string `json:"name"`
1517
Uri string `json:"uri"`
@@ -34,7 +36,7 @@ func FetchAndSaveTags(cmd *cobra.Command) error {
3436
return err
3537
}
3638
// HTTP GET request (extracted)
37-
resp, err := GetAPIResponse(ApiUrl + "tags")
39+
resp, err := GetAPIResponse(APIUrl + "tags")
3840
if err != nil {
3941
log.Error().Err(err).Msg("Error during HTTP request")
4042
return err
@@ -105,7 +107,7 @@ func GetTagsWithCacheRefresh(cmd *cobra.Command, tagsPath string) (TagsFile, err
105107
return tags, nil
106108
}
107109

108-
// readAndUnmarshalTags lit le fichier et fait l'unmarshal JSON dans tags.
110+
// readAndUnmarshalTags reads the file and unmarshals the JSON contents into tags.
109111
func readAndUnmarshalTags(tagsPath string, tags *TagsFile) error {
110112
data, err := os.ReadFile(tagsPath)
111113
if err != nil {
@@ -124,7 +126,7 @@ func ConvertTagStringsToTags(tagStrings []string) []Tag {
124126
for i, tagName := range tagStrings {
125127
tags[i] = Tag{
126128
Name: tagName,
127-
Uri: "https://endoflife.date/api/v1/tags/" + tagName,
129+
Uri: tagBaseURL + tagName,
128130
}
129131
}
130132
return tags

0 commit comments

Comments
 (0)