lukecarr/trophies

View on GitHub

Showing 21 of 21 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        <div
          className="grid gap-6 lg:gap-3"
          style={{ gridTemplateColumns: `repeat(${new Set(counts.map(x => x.rarity)).size}, minmax(0, 1fr))` }}
        >
          {counts.sort((a, b) => {
Severity: Major
Found in frontend/src/routes/home.tsx and 1 other location - About 1 day to fix
frontend/src/routes/home.tsx on lines 99..114

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 211.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        <div
          className="grid gap-6 lg:gap-3"
          style={{ gridTemplateColumns: `repeat(${new Set(counts.map(x => x.rarity)).size}, minmax(0, 1fr))` }}
        >
          {counts.sort((a, b) => {
Severity: Major
Found in frontend/src/routes/home.tsx and 1 other location - About 1 day to fix
frontend/src/routes/home.tsx on lines 55..70

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 211.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      <div className="h-32 w-32 bg-cover bg-center flex" style={{ backgroundImage: `url(${game.iconURL})` }}>
        <div className="backdrop-blur-lg flex items-center justify-center">
          <img className="w-full" src={game.iconURL} alt={name} />
        </div>
      </div>
Severity: Major
Found in frontend/src/routes/home.tsx and 1 other location - About 2 hrs to fix
frontend/src/routes/home.tsx on lines 82..86

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 92.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        <div className="h-full w-full bg-cover bg-center flex" style={{ backgroundImage: `url(${game.iconURL})` }}>
          <div className="backdrop-blur-lg flex items-center justify-center">
            <img className="w-full" src={game.iconURL} alt={name} />
          </div>
        </div>
Severity: Major
Found in frontend/src/routes/home.tsx and 1 other location - About 2 hrs to fix
frontend/src/routes/home.tsx on lines 46..50

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 92.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func getAllGames(e *env.Env) func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
        return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
            games, err := e.Services.Game.GetAll()
            if err != nil {
                http.Error(w, err.Error(), http.StatusInternalServerError)
    Severity: Major
    Found in internal/routes/game.go and 1 other location - About 2 hrs to fix
    internal/routes/game.go on lines 143..156

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 227.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func getAllGameTrophyCounts(e *env.Env) func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
        return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
            games, err := e.Services.Game.GetCounts()
            if err != nil {
                http.Error(w, err.Error(), http.StatusInternalServerError)
    Severity: Major
    Found in internal/routes/game.go and 1 other location - About 2 hrs to fix
    internal/routes/game.go on lines 21..34

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 227.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (v *JsonNullInt64) UnmarshalJSON(data []byte) error {
          // Unmarshalling into a pointer will let us detect null
          var x *int64
          if err := json.Unmarshal(data, &x); err != nil {
              return err
      Severity: Minor
      Found in internal/models/game.go and 1 other location - About 55 mins to fix
      internal/models/game.go on lines 64..77

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 124.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (v *JsonNullString) UnmarshalJSON(data []byte) error {
          // Unmarshalling into a pointer will let us detect null
          var x *string
          if err := json.Unmarshal(data, &x); err != nil {
              return err
      Severity: Minor
      Found in internal/models/game.go and 1 other location - About 55 mins to fix
      internal/models/game.go on lines 37..50

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 124.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                        counts={(counts ?? []).filter(({ id, rarity }) => id === x.id && rarity !== "platinum")}
      Severity: Minor
      Found in frontend/src/routes/home.tsx and 1 other location - About 50 mins to fix
      frontend/src/routes/home.tsx on lines 175..175

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 51.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                        counts={(counts ?? []).filter(({ id, rarity }) => id === x.id && rarity !== "platinum")}
      Severity: Minor
      Found in frontend/src/routes/home.tsx and 1 other location - About 50 mins to fix
      frontend/src/routes/home.tsx on lines 187..187

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 51.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

            const GameCard = ({ game, counts }: { game: Game; counts: Omit<GameCount, "id">[] }) => {
              const name = game.name.trim();
            
              return (
                <div className="bg-gray-100 dark:bg-slate-800 flex relative">
            Severity: Minor
            Found in frontend/src/routes/home.tsx and 1 other location - About 35 mins to fix
            frontend/src/routes/home.tsx on lines 76..118

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 47.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

            const GameRow = ({ game, counts }: { game: Game; counts: Omit<GameCount, "id">[] }) => {
              const name = game.name.trim();
            
              return (
                <tr className="bg-gray-100 even:bg-gray-200 dark:bg-slate-800 dark:even:bg-slate-700">
            Severity: Minor
            Found in frontend/src/routes/home.tsx and 1 other location - About 35 mins to fix
            frontend/src/routes/home.tsx on lines 38..74

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 47.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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
                Severity
                Category
                Status
                Source
                Language