lukecarr/trophies

View on GitHub

Showing 9 of 21 total issues

Function Home has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Home: FunctionalComponent = () => {
  const { data } = useSWR<Game[]>("/games");
  const { data: counts } = useSWR<GameCount[]>("/gamesCounts");

  if (!data || !counts) return <p>Loading...</p>;
Severity: Major
Found in frontend/src/routes/home.tsx - About 2 hrs to fix

    Function MakeFetchCmd has 76 lines of code (exceeds 50 allowed). Consider refactoring.
    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) {
    Severity: Major
    Found in cmd/fetch.go - About 2 hrs to fix

      Function fetchAccessCode has 7 return statements (exceeds 4 allowed).
      Open

      func fetchAccessCode(npssoToken string) (string, error) {
          client := &http.Client{
              CheckRedirect: func(req *http.Request, via []*http.Request) error {
                  return http.ErrUseLastResponse
              },
      Severity: Major
      Found in internal/services/psn.go - About 45 mins to fix

        Function MakeFetchCmd has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
        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) {
        Severity: Minor
        Found in cmd/fetch.go - About 45 mins to fix

        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

        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
            }
        Severity: Major
        Found in internal/services/psn.go - About 40 mins to fix

          Method PsnClient.GetTrophyGroups has 6 return statements (exceeds 4 allowed).
          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},
              }
          Severity: Major
          Found in internal/services/psn.go - About 40 mins to fix

            Method PsnClient.GetTrophies has 5 return statements (exceeds 4 allowed).
            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},
                }
            Severity: Major
            Found in internal/services/psn.go - About 35 mins to fix

              Method MetadataServiceRawg.SearchGame has 5 return statements (exceeds 4 allowed).
              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, "")
              Severity: Major
              Found in internal/services/metadata.go - About 35 mins to fix

                Function fetchAccessToken has 5 return statements (exceeds 4 allowed).
                Open

                func fetchAccessToken(accessCode string) (string, string, error) {
                    client := &http.Client{}
                
                    data := url.Values{
                        "code":         {accessCode},
                Severity: Major
                Found in internal/services/psn.go - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language