Skip to content
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

setup golangci-lint and go-test workflow #12

Merged
merged 2 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Go Test Workflow

on: [pull_request]

jobs:
go-test-service:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Run go test
run: cd src && go test -v ./...
21 changes: 21 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint Workflow

on: [pull_request]

jobs:
golangci-lint-service:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest

163 changes: 163 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
---
# golangci-lint configuration file made by @ccoVeille
# Source: https://github.com/ccoVeille/golangci-lint-config-examples/
# Author: @ccoVeille
# License: MIT
# Variant: 03-safe
# Version: v1.1.0
#
linters:
# some linters are enabled by default
# https://golangci-lint.run/usage/linters/
#
# enable some extra linters
enable:
# Errcheck is a program for checking for unchecked errors in Go code.
- errcheck

# Linter for Go source code that specializes in simplifying code.
- gosimple

# Vet examines Go source code and reports suspicious constructs.
- govet

# Detects when assignments to existing variables are not used.
- ineffassign

# It's a set of rules from staticcheck. See https://staticcheck.io/
- staticcheck

# Fast, configurable, extensible, flexible, and beautiful linter for Go.
# Drop-in replacement of golint.
- revive

# check imports order and makes it always deterministic.
# - gci
- goimports

# make sure to use t.Helper() when needed
- thelper

# mirror suggests rewrites to avoid unnecessary []byte/string conversion
- mirror

# detect the possibility to use variables/constants from the Go standard library.
- usestdlibvars

# Finds commonly misspelled English words.
- misspell

# Checks for duplicate words in the source code.
- dupword

# linter to detect errors invalid key values count
- loggercheck

# detects nested contexts in loops or function literals
- fatcontext

linters-settings:
gci: # define the section orders for imports
sections:
# Standard section: captures all standard packages.
- standard
# Default section: catchall that is not standard or custom
- default
# linters that related to local tool, so they should be separated
- localmodule

revive:
rules:
# these are the default revive rules
# you can remove the whole "rules" node if you want
# BUT
# ! /!\ they all need to be present when you want to add more rules than the default ones
# otherwise, you won't have the default rules, but only the ones you define in the "rules" node

# Blank import should be only in a main or test package, or have a comment justifying it.
- name: blank-imports

# context.Context() should be the first parameter of a function when provided as argument.
- name: context-as-argument
arguments:
- allowTypesBefore: "*testing.T"

# Basic types should not be used as a key in `context.WithValue`
- name: context-keys-type

# Importing with `.` makes the programs much harder to understand
- name: dot-imports

# Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring.
- name: empty-block

# for better readability, variables of type `error` must be named with the prefix `err`.
- name: error-naming

# for better readability, the errors should be last in the list of returned values by a function.
- name: error-return

# for better readability, error messages should not be capitalized or end with punctuation or a newline.
- name: error-strings

# report when replacing `errors.New(fmt.Sprintf())` with `fmt.Errorf()` is possible
- name: errorf

# incrementing an integer variable by 1 is recommended to be done using the `++` operator
- name: increment-decrement

# highlights redundant else-blocks that can be eliminated from the code
- name: indent-error-flow

# This rule suggests a shorter way of writing ranges that do not use the second value.
- name: range

# receiver names in a method should reflect the struct name (p for Person, for example)
- name: receiver-naming

# redefining built in names (true, false, append, make) can lead to bugs very difficult to detect.
- name: redefines-builtin-id

# redundant else-blocks that can be eliminated from the code.
- name: superfluous-else

# prevent confusing name for variables when using `time` package
- name: time-naming

# warns when an exported function or method returns a value of an un-exported type.
- name: unexported-return

# spots and proposes to remove unreachable code. also helps to spot errors
- name: unreachable-code

# Functions or methods with unused parameters can be a symptom of an unfinished refactoring or a bug.
- name: unused-parameter

# report when a variable declaration can be simplified
- name: var-declaration

# warns when initialism, variable or package naming conventions are not followed.
- name: var-naming

dupword:
# Keywords used to ignore detection.
# Default: []
ignore:
# - "blah" # this will accept "blah blah …" as a valid duplicate word

misspell:
# Correct spellings using locale preferences for US or UK.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
# Default ("") is to use a neutral variety of English.
locale: US

# List of words to ignore
# among the one defined in https://github.com/golangci/misspell/blob/master/words.go
ignore-words:
# - valor
# - and

# Extra word corrections.
extra-words:
# - typo: "whattever"
# correction: "whatever"
9 changes: 5 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@ package main
import (
"flag"
"fmt"
kaizen "github.com/serene-brew/Kaizen/src"
"os"
"os/exec"

kaizen "github.com/serene-brew/Kaizen/src"
)

// Main entrypoint for the application
func main() {
//perform auto-heal check before starting kaizen
// perform auto-heal check before starting kaizen
kaizen.AutoHeal()

//check whether MPV-player is installed or not
// check whether MPV-player is installed or not
_, err := exec.LookPath("mpv")
if err != nil {
fmt.Println("[!] Please install MPV-player using your package manager before running kaizen")
os.Exit(1)
}

//kaizen CLI flags
// kaizen CLI flags
uninstalFlag := flag.Bool("uninstall", false, "Run the uninstaller script")
updateFlag := flag.Bool("update", false, "Run the update script")
versionFlag := flag.Bool("v", false, "views version information")
Expand Down
4 changes: 2 additions & 2 deletions src/APIcore.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ If an error occurs at any point, it is returned along with an empty string.
resp -> string [Stream link]
*/
func getStreamLink(id string, espisodeType string, episodeNumber string) (string, error) {
apiUrl := "https://heavenscape.vercel.app/api/anime/search/" + id + "/" + espisodeType + "/" + episodeNumber
apiURL := "https://heavenscape.vercel.app/api/anime/search/" + id + "/" + espisodeType + "/" + episodeNumber

resp, err := http.Get(apiUrl)
resp, err := http.Get(apiURL)
if err != nil {
return "", err
}
Expand Down
66 changes: 33 additions & 33 deletions src/WatchAnime.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,36 @@ var (
keys = newKeyMap()
)

type focus int
type Tab1Model struct {
focus focus
styles Tab1styles
inputM textinput.Model
listOne list.Model
listTwo list.Model
table table.Model
spinner spinner.Model

loading bool
loadingMSG string
data [][]interface{}

width int
height int

animeID string
animeName string
subEpisodeNumber int
dubEpisodeNumber int
subSelectedNum string
dubSelectedNum string
episodeType string
streamLink string
availableSubEpisodes []string
availableDubEpisodes []string
}
type (
focus int
Tab1Model struct {
focus focus
styles Tab1styles
inputM textinput.Model
listOne list.Model
listTwo list.Model
table table.Model
spinner spinner.Model

loading bool
loadingMSG string
data [][]interface{}

width int
height int //nolint:unused

animeID string
animeName string
subEpisodeNumber int
dubEpisodeNumber int
subSelectedNum string
dubSelectedNum string
episodeType string
streamLink string
availableSubEpisodes []string
availableDubEpisodes []string
}
)

type item struct {
title string
Expand Down Expand Up @@ -86,7 +88,7 @@ func NewTab1Model() Tab1Model {

spin := spinner.New()
spin.Spinner = spinner.Dot
spin.Style = lipgloss.NewStyle().Foreground(lipgloss.Color(conf.Tab1_SpinnerColor))
spin.Style = lipgloss.NewStyle().Foreground(lipgloss.Color(conf.Tab1SpinnerColor))

columns := []table.Column{
{Title: "", Width: 10},
Expand Down Expand Up @@ -238,7 +240,6 @@ func (m Tab1Model) Update(msg tea.Msg) (Tab1Model, tea.Cmd) {
m.styles.list2Border = m.styles.list2Border.BorderForeground(lipgloss.Color(m.styles.inactiveColor))
m.styles.tableBorder = m.styles.tableBorder.BorderForeground(lipgloss.Color(m.styles.inactiveColor))
}

} else if m.focus == listOneFocus {
m.streamSubAnime()
m.styles.inputBorder = m.styles.inputBorder.BorderForeground(lipgloss.Color(m.styles.inactiveColor))
Expand All @@ -254,7 +255,6 @@ func (m Tab1Model) Update(msg tea.Msg) (Tab1Model, tea.Cmd) {
}
return m, nil
}

}

// Update the active component based on focus, and return a batch of commands
Expand Down Expand Up @@ -314,15 +314,15 @@ func (m Tab1Model) View() string {
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣴⣿⡿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣿⣿⣿⣶⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣾⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⠟⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠛⠛⠉⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣿⣿⣶⣶⣶⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣿⡿⠛⠛⠛⠛⠉⠉⠉⠉⠉⠉⠉`
asciiS := lipgloss.NewStyle().Foreground(lipgloss.Color(conf.Tab1_kaizen_AscciArtColor))
asciiS := lipgloss.NewStyle().Foreground(lipgloss.Color(conf.Tab1KaizenAscciArtColor))
if m.loading {
return lipgloss.JoinVertical(
lipgloss.Top,
inputS,
lipgloss.JoinHorizontal(
lipgloss.Top,
m.spinner.View(),
lipgloss.NewStyle().Foreground(lipgloss.Color(conf.Tab1_SpinnerMsgColor)).Render(m.loadingMSG)),
lipgloss.NewStyle().Foreground(lipgloss.Color(conf.Tab1SpinnerMsgColor)).Render(m.loadingMSG)),
tableS,
lipgloss.JoinHorizontal(
lipgloss.Top,
Expand Down
Loading
Loading