Showing 9 of 21 total issues
Function Home
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Home: FunctionalComponent = () => {
const { data } = useSWR<Game[]>("/games");
const { data: counts } = useSWR<GameCount[]>("/gamesCounts");
if (!data || !counts) return <p>Loading...</p>;
Function MakeFetchCmd
has 76 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func MakeFetchCmd() *cobra.Command {
return &cobra.Command{
Use: "fetch",
Short: "Fetches games, trophy lists, and trophy completion data from PSN.",
Run: func(cmd *cobra.Command, args []string) {
Function fetchAccessCode
has 7 return statements (exceeds 4 allowed). Open
Open
func fetchAccessCode(npssoToken string) (string, error) {
client := &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
Function MakeFetchCmd
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func MakeFetchCmd() *cobra.Command {
return &cobra.Command{
Use: "fetch",
Short: "Fetches games, trophy lists, and trophy completion data from PSN.",
Run: func(cmd *cobra.Command, args []string) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method PsnClient.GetTitles
has 6 return statements (exceeds 4 allowed). Open
Open
func (c *PsnClient) GetTitles() ([]Title, error) {
req, err := http.NewRequest("GET", "https://m.np.playstation.com/api/trophy/v1/users/me/trophyTitles?limit=800", nil)
if err != nil {
return nil, err
}
Method PsnClient.GetTrophyGroups
has 6 return statements (exceeds 4 allowed). Open
Open
func (c *PsnClient) GetTrophyGroups(gameID, service string) ([]TrophyGroup, error) {
requestURL := fmt.Sprintf("https://m.np.playstation.com/api/trophy/v1/npCommunicationIds/%v/trophyGroups", gameID)
params := url.Values{
"npServiceName": {service},
}
Method PsnClient.GetTrophies
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *PsnClient) GetTrophies(gameID, service string) ([]Trophy, error) {
requestURL := fmt.Sprintf("https://m.np.playstation.com/api/trophy/v1/npCommunicationIds/%v/trophyGroups/all/trophies", gameID)
params := url.Values{
"npServiceName": {service},
}
Method MetadataServiceRawg.SearchGame
has 5 return statements (exceeds 4 allowed). Open
Open
func (m *MetadataServiceRawg) SearchGame(name, platform, excludePlatforms string) (*GameMetadata, error) {
requestURL := "https://api.rawg.io/api/games"
// Remove all non-ASCII characters from name (i.e. trademark symbols, copyright, etc.)
name = regexp.MustCompile(`[^\x00-\x7F]+`).ReplaceAllString(name, "")
Function fetchAccessToken
has 5 return statements (exceeds 4 allowed). Open
Open
func fetchAccessToken(accessCode string) (string, string, error) {
client := &http.Client{}
data := url.Values{
"code": {accessCode},