jkawamoto/loci

View on GitHub

Showing 61 of 61 total issues

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

func assetsDockerfileGo() (*asset, error) {
    bytes, err := assetsDockerfileGoBytes()
    if err != nil {
        return nil, err
    }
Severity: Major
Found in command/assets.go and 5 other locations - About 40 mins to fix
command/assets.go on lines 85..94
command/assets.go on lines 125..134
command/assets.go on lines 145..154
command/assets.go on lines 165..174
command/assets.go on lines 185..194

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

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

func assetsEntrypointGo() (*asset, error) {
    bytes, err := assetsEntrypointGoBytes()
    if err != nil {
        return nil, err
    }
Severity: Major
Found in command/assets.go and 5 other locations - About 40 mins to fix
command/assets.go on lines 85..94
command/assets.go on lines 105..114
command/assets.go on lines 125..134
command/assets.go on lines 145..154
command/assets.go on lines 185..194

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

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 NewDisplay has 6 return statements (exceeds 4 allowed).
Open

func NewDisplay(ctx context.Context, title string, maxSection int) (display *Display, nctx context.Context, err error) {

    g, err := gocui.NewGui(gocui.OutputNormal)
    if err != nil {
        return
Severity: Major
Found in command/display.go - About 40 mins to fix

    Function archiveContext has 6 return statements (exceeds 4 allowed).
    Open

    func archiveContext(ctx context.Context, root string, writer io.Writer) (err error) {
    
        // Create a buffered writer.
        bufWriter := bufio.NewWriter(writer)
        defer bufWriter.Flush()
    Severity: Major
    Found in command/docker.go - About 40 mins to fix

      Function Dockerfile has 6 return statements (exceeds 4 allowed).
      Open

      func Dockerfile(travis *Travis, opt *DockerfileOpt, archive string) (res []byte, err error) {
      
          var data []byte
      
          // Loading the base template.
      Severity: Major
      Found in command/docker.go - About 40 mins to fix

        Function RestoreAsset has 6 return statements (exceeds 4 allowed).
        Open

        func RestoreAsset(dir, name string) error {
            data, err := Asset(name)
            if err != nil {
                return err
            }
        Severity: Major
        Found in command/assets.go - About 40 mins to fix

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

          func parseMatrixPython(v interface{}) (version string, c TestCase, err error) {
          
              m, ok := v.(map[interface{}]interface{})
              if !ok {
                  err = fmt.Errorf("Given item is broken.")
          Severity: Major
          Found in command/travis_python.go - About 35 mins to fix

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

            func Entrypoint(travis *Travis) (res []byte, err error) {
            
                var (
                    data []byte
                    temp *template.Template
            Severity: Major
            Found in command/entrypoint.go - About 35 mins to fix

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

              func Build(ctx context.Context, dir, tag, version string, noCache bool, output io.Writer) (err error) {
              
                  // Create a docker client.
                  cli, err := client.NewEnvClient()
                  if err != nil {
              Severity: Major
              Found in command/docker.go - About 35 mins to fix

                Method Display.Layout has 5 return statements (exceeds 4 allowed).
                Open

                func (d *Display) Layout(g *gocui.Gui) error {
                    if d.closed {
                        return fmt.Errorf("Display has been closed already")
                    }
                
                
                Severity: Major
                Found in command/display.go - About 35 mins to fix

                  Function TestPythonArgumentSetWithFullDescriptions has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func TestPythonArgumentSetWithFullDescriptions(t *testing.T) {
                  
                      travis, err := storeAndLoadTravis(&Travis{
                          Language: "python",
                          Python:   []string{"2.7", "3.5"},
                  Severity: Minor
                  Found in command/travis_python_test.go - 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

                  Function TestGoArgumentSetWithFullDescriptions has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func TestGoArgumentSetWithFullDescriptions(t *testing.T) {
                  
                      travis, err := storeAndLoadTravis(&Travis{
                          Language: "go",
                          Go:       []string{"1.6", "1.7"},
                  Severity: Minor
                  Found in command/travis_go_test.go - 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

                  Your code does not pass gofmt in 4 places. Go fmt your code!
                  Open

                  // Code generated by go-bindata.
                  Severity: Minor
                  Found in command/assets.go by gofmt

                  error strings should not be capitalized or end with punctuation or a newline
                  Open

                          err = fmt.Errorf("Given item is broken.")
                  Severity: Minor
                  Found in command/travis_python.go by golint

                  error strings should not be capitalized or end with punctuation or a newline
                  Open

                                      fmt.Errorf("%v\n%v\n%v\n", msg, err.Error(), sec.String()))
                  Severity: Minor
                  Found in command/run.go by golint

                  error strings should not be capitalized or end with punctuation or a newline
                  Open

                          err = fmt.Errorf("Given item is broken.")
                  Severity: Minor
                  Found in command/travis_go.go by golint

                  error strings should not be capitalized or end with punctuation or a newline
                  Open

                          err = fmt.Errorf("Env of the given item is broken.")
                  Severity: Minor
                  Found in command/travis_go.go by golint

                  error strings should not be capitalized or end with punctuation or a newline
                  Open

                          err = fmt.Errorf("Env of the given item is broken.")
                  Severity: Minor
                  Found in command/travis_python.go by golint

                  Your code does not pass gofmt in 1 place. Go fmt your code!
                  Open

                  //
                  Severity: Minor
                  Found in command/travis_go_test.go by gofmt

                  Your code does not pass gofmt in 1 place. Go fmt your code!
                  Open

                  //
                  Severity: Minor
                  Found in command/travis_python_test.go by gofmt
                  Severity
                  Category
                  Status
                  Source
                  Language