minepkg/minepkg

View on GitHub

Showing 129 of 129 total issues

Method publishRunner.RunE has a Cognitive Complexity of 62 (exceeds 20 allowed). Consider refactoring.
Open

func (p *publishRunner) RunE(cmd *cobra.Command, args []string) error {
    apiClient := root.MinepkgAPI
    nonInteractive := viper.GetBool("nonInteractive")

    tasks := logger.NewTask(3)
Severity: Minor
Found in cmd/publish.go - About 7 hrs 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 2 locations. Consider refactoring.
Open

        Repository struct {
            ID       int    `json:"id"`
            NodeID   string `json:"node_id"`
            Name     string `json:"name"`
            FullName string `json:"full_name"`
Severity: Major
Found in internals/github/actions.go and 1 other location - About 6 hrs to fix
internals/github/actions.go on lines 159..225

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

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

        HeadRepository struct {
            ID       int    `json:"id"`
            NodeID   string `json:"node_id"`
            Name     string `json:"name"`
            FullName string `json:"full_name"`
Severity: Major
Found in internals/github/actions.go and 1 other location - About 6 hrs to fix
internals/github/actions.go on lines 92..158

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

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 publishRunner.RunE has 182 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (p *publishRunner) RunE(cmd *cobra.Command, args []string) error {
    apiClient := root.MinepkgAPI
    nonInteractive := viper.GetBool("nonInteractive")

    tasks := logger.NewTask(3)
Severity: Major
Found in cmd/publish.go - About 6 hrs to fix

    Method launchRunner.RunE has a Cognitive Complexity of 53 (exceeds 20 allowed). Consider refactoring.
    Open

    func (l *launchRunner) RunE(cmd *cobra.Command, args []string) error {
        var err error
    
        vanillaManifest.Requirements.Minecraft = "*"
        vanillaManifest.Requirements.MinepkgCompanion = "none"
    Severity: Minor
    Found in cmd/launch.go - About 5 hrs 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 launchRunner.RunE has 151 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (l *launchRunner) RunE(cmd *cobra.Command, args []string) error {
        var err error
    
        vanillaManifest.Requirements.Minecraft = "*"
        vanillaManifest.Requirements.MinepkgCompanion = "none"
    Severity: Major
    Found in cmd/launch.go - About 5 hrs to fix

      Method initRunner.RunE has 141 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (i *initRunner) RunE(cmd *cobra.Command, args []string) error {
          if _, err := ioutil.ReadFile("./minepkg.toml"); err == nil && !i.force {
              return fmt.Errorf("this directory already contains a minepkg.toml. Use --force to overwrite it")
          }
      
      
      Severity: Major
      Found in cmd/initCmd/initCmd.go - About 4 hrs to fix

        Method Instance.BuildLaunchCmd has 132 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (i *Instance) BuildLaunchCmd(opts *LaunchOptions) (*exec.Cmd, error) {
            // this file tells us how to construct the start command
            launchManifest := opts.LaunchManifest
            var err error
        
        
        Severity: Major
        Found in internals/instances/launch.go - About 4 hrs to fix

          Method tryRunner.RunE has 121 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (t *tryRunner) RunE(cmd *cobra.Command, args []string) error {
              apiClient := root.MinepkgAPI
              nonInteractive := viper.GetBool("nonInteractive")
          
              tempDir, err := ioutil.TempDir("", args[0])
          Severity: Major
          Found in cmd/try.go - About 3 hrs to fix

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

            func (m *MicrosoftClient) xstsAuth(ctx context.Context, xblToken string) (*xblAuthResponse, error) {
                body := fmt.Sprintf(`{
                    "Properties": {
                            "SandboxId": "RETAIL",
                            "UserTokens": ["%s"]
            Severity: Major
            Found in internals/minecraft/microsoft/2-xbox-login.go and 1 other location - About 3 hrs to fix
            internals/minecraft/microsoft/2-xbox-login.go on lines 36..69

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

            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 (m *MicrosoftClient) xblAuth(ctx context.Context, token string) (*xblAuthResponse, error) {
                body := fmt.Sprintf(`{
                    "Properties": {
                            "AuthMethod": "RPS",
                            "SiteName": "user.auth.xboxlive.com",
            Severity: Major
            Found in internals/minecraft/microsoft/2-xbox-login.go and 1 other location - About 3 hrs to fix
            internals/minecraft/microsoft/2-xbox-login.go on lines 71..103

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

            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 TheThing.Launch has 106 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (t *TheThing) Launch(man *manifest.Manifest) error {
                connection := t.Connection
                t.State.Status = StatusStarting
            
                if root.authProvider == nil {
            Severity: Major
            Found in cmd/proto-handler.go - About 3 hrs to fix

              Method MinepkgClient.FindRelease has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
              Open

              func (m *MinepkgClient) FindRelease(ctx context.Context, project string, reqs *RequirementQuery) (*Release, error) {
                  p := Project{client: m, Name: project}
              
                  var wantedMCSemver *semver.Version
                  if reqs.Minecraft != "*" {
              Severity: Minor
              Found in internals/api/find-release.go - About 3 hrs 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 installRunner.installFromMinepkg has 99 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (i *installRunner) installFromMinepkg(mods []string) error {
                  instance := i.instance
                  apiClient := root.MinepkgAPI
              
                  task := logger.NewTask(3)
              Severity: Major
              Found in cmd/install-minepkg.go - About 2 hrs to fix

                Method tryRunner.RunE has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
                Open

                func (t *tryRunner) RunE(cmd *cobra.Command, args []string) error {
                    apiClient := root.MinepkgAPI
                    nonInteractive := viper.GetBool("nonInteractive")
                
                    tempDir, err := ioutil.TempDir("", args[0])
                Severity: Minor
                Found in cmd/try.go - About 2 hrs 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 bumpRunner.RunE has 95 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (b *bumpRunner) RunE(cmd *cobra.Command, args []string) error {
                
                    instance, err := instances.NewFromWd()
                
                    if err != nil {
                Severity: Major
                Found in cmd/bump/bump.go - About 2 hrs to fix

                  Method unpublishRunner.RunE has 92 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (p *unpublishRunner) RunE(cmd *cobra.Command, args []string) error {
                      apiClient := root.MinepkgAPI
                      // nonInteractive := viper.GetBool("nonInteractive")
                  
                      var mID *pkgid.ID
                  Severity: Major
                  Found in cmd/unpublish.go - About 2 hrs to fix

                    Method Instance.BuildLaunchCmd has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (i *Instance) BuildLaunchCmd(opts *LaunchOptions) (*exec.Cmd, error) {
                        // this file tells us how to construct the start command
                        launchManifest := opts.LaunchManifest
                        var err error
                    
                    
                    Severity: Minor
                    Found in internals/instances/launch.go - About 2 hrs 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 dependenciesInSync has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func dependenciesInSync(lock *manifest.Lockfile, mani *manifest.Manifest) (bool, error) {
                        if mani == nil {
                            return false, fmt.Errorf("manifest is nil")
                        }
                    
                    
                    Severity: Minor
                    Found in internals/instances/synced.go - About 2 hrs 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 Connection.ListenForHandshake has 79 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (c *Connection) ListenForHandshake(ctx context.Context) error {
                        dataChannelOpen := make(chan struct{})
                    
                        server := http.Server{Addr: "localhost:20876"}
                        c.httpServer = &server
                    Severity: Major
                    Found in internals/remote/handshake.go - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language