dalexhd/SteamSpeak

View on GitHub

Showing 97 of 107 total issues

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

    try {
        const [client] = await findClients(
            req,
            {
                clientType: 0,
Severity: Major
Found in packages/server/src/core/Website/api/controllers/auth.ts and 4 other locations - About 45 mins to fix
packages/server/src/core/Website/api/controllers/auth.ts on lines 69..83
packages/server/src/core/Website/api/controllers/auth.ts on lines 138..170
packages/server/src/core/Website/api/controllers/auth.ts on lines 181..190
packages/server/src/core/Website/api/controllers/auth.ts on lines 201..215

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 50.

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 drawTextWithEmoji has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

Canvas.CanvasRenderingContext2D.prototype.drawTextWithEmoji = async function (
    fillType: string,
    text: string,
    x: number,
    y: number,
Severity: Minor
Found in packages/server/src/utils/canvas/custom.ts - 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

Function checkDescriptionBanner has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const checkDescriptionBanner = async (
    client: TeamSpeakClient | undefined,
    presenceString: string | undefined,
    data: SteamUser.PersonaData,
    steamId: string
Severity: Minor
Found in packages/server/src/core/Steam/modules/richPresence.ts - 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 component has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def component
    return @component if defined?(@component)

    component_name = name.split(" ").first

Severity: Minor
Found in scripts/util/metadata/commit_scope.rb - 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

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

    try {
        const steamData = await findSecret(req);
        const clients = await findClients(req, {
            clientType: 0
        });
Severity: Major
Found in packages/server/src/core/Website/api/controllers/verify.ts and 3 other locations - About 45 mins to fix
packages/server/src/core/Website/api/controllers/logs.ts on lines 13..33
packages/server/src/core/Website/api/controllers/verify.ts on lines 57..88
packages/server/src/core/Website/api/controllers/verify.ts on lines 100..138

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 50.

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

Consider simplifying this complex logical expression.
Open

    if (
        data.diff?.game_played_app_id?.to === info.appId ||
        (data.diff?.rich_presence?.from.find((e) => e.key === 'game:state')?.value === 'game' &&
            data.diff?.rich_presence?.to.find((e) => e.key === 'game:state')?.value === 'lobby' &&
            data.diff?.rich_presence?.from.find((e) => e.key === 'game:mode')?.value === 'competitive' &&
Severity: Major
Found in packages/server/src/core/Steam/games/csgo.ts - About 40 mins to fix

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

        for (const key in replacements) {
            if (!replacements.hasOwnProperty(key)) continue;
            message = message.replace(key, replacements[key]);
        }
    packages/server/src/core/TeamSpeak/plugins/first-instance/multi_function.ts on lines 19..22
    packages/server/src/core/TeamSpeak/plugins/second-instance/server_name.ts on lines 27..30

    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 48.

    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 3 locations. Consider refactoring.
    Open

            for (const key in replacements) {
                if (!replacements.hasOwnProperty(key)) continue;
                name = name.replace(key, replacements[key]);
            }
    packages/server/src/core/TeamSpeak/plugins/first-instance/host_message.ts on lines 27..30
    packages/server/src/core/TeamSpeak/plugins/second-instance/server_name.ts on lines 27..30

    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 48.

    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 3 locations. Consider refactoring.
    Open

        for (const key in edited_name) {
            if (!edited_name.hasOwnProperty(key)) continue;
            name = name.replace(key, edited_name[key]);
        }
    packages/server/src/core/TeamSpeak/plugins/first-instance/host_message.ts on lines 27..30
    packages/server/src/core/TeamSpeak/plugins/first-instance/multi_function.ts on lines 19..22

    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 48.

    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

    Avoid too many return statements within this function.
    Open

                    return `${lang.steam.status.Playing} ${lang.message.to} ${steamData.game_name}`;
    Severity: Major
    Found in packages/server/src/utils/steam/components/friends.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return 'xs';
      Severity: Major
      Found in packages/client/src/store/getters.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return `${lang.steam.status.Playing} ${lang.message.to} ${app.appinfo.common.name}`;
        Severity: Major
        Found in packages/server/src/utils/steam/components/friends.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return lang.steam.status.Playing;
          Severity: Major
          Found in packages/server/src/utils/steam/components/friends.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return undefined;
            Severity: Major
            Found in packages/server/src/utils/steam/components/friends.ts - About 30 mins to fix

              Method bump_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def bump_type(other_version)
                  # Return nil if the other version is not greater than the current version
                  if other_version <= self
                    return nil
                  end
              Severity: Minor
              Found in scripts/util/version.rb - About 25 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 components has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def components
                  return @components if defined?(@components)
              
                  @components =
                    if new_feature?
              Severity: Minor
              Found in scripts/util/metadata/commit.rb - About 25 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 continuize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def continuize
                  i = 0
              
                  loop do
                    if i > self.length
              Severity: Minor
              Found in scripts/util/core_ext/string.rb - About 25 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

              Severity
              Category
              Status
              Source
              Language