Kerrigan29a/recipe

View on GitHub

Showing 80 of 80 total issues

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

func (r *Recipe) serialize(indent bool) *bytes.Buffer {
    r.mu.RLock()
    defer r.mu.RUnlock()
    b := bytes.Buffer{}
    e := json.NewEncoder(&b)
Severity: Major
Found in recipe.go and 2 other locations - About 1 hr to fix
state.go on lines 90..103
task.go on lines 210..223

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

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

func (t *Task) serialize(indent bool) *bytes.Buffer {
    t.mu.RLock()
    defer t.mu.RUnlock()
    b := bytes.Buffer{}
    e := json.NewEncoder(&b)
Severity: Major
Found in task.go and 2 other locations - About 1 hr to fix
recipe.go on lines 295..308
state.go on lines 90..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 143.

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

func (s *State) serialize(indent bool) *bytes.Buffer {
    s.mu.Lock()
    defer s.mu.Unlock()
    b := bytes.Buffer{}
    e := json.NewEncoder(&b)
Severity: Major
Found in state.go and 2 other locations - About 1 hr to fix
recipe.go on lines 295..308
task.go on lines 210..223

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

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

func Open(path string, recipeLogger, stateLogger *Logger) (*Recipe, error) {
    var r Recipe
    f, err := os.Open(path)
    if err != nil {
        return nil, fmt.Errorf("(%s) %s", path, err.Error())
Severity: Major
Found in recipe.go - About 45 mins to fix

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

    func (s *State) MustSetWaiting(taskName string) {
        s.mu.Lock()
        defer s.mu.Unlock()
        if s.States[taskName] != Enabled {
            panic(fmt.Errorf("Current state must be Enabled, not %s", s.States[taskName].String()))
    Severity: Major
    Found in state.go and 4 other locations - About 45 mins to fix
    state.go on lines 149..156
    state.go on lines 164..171
    state.go on lines 179..186
    state.go on lines 194..201

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

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

    func (s *State) MustSetRunning(taskName string) {
        s.mu.Lock()
        defer s.mu.Unlock()
        if s.States[taskName] != Waiting {
            panic(fmt.Errorf("Current state must be Waiting, not %s", s.States[taskName].String()))
    Severity: Major
    Found in state.go and 4 other locations - About 45 mins to fix
    state.go on lines 134..141
    state.go on lines 164..171
    state.go on lines 179..186
    state.go on lines 194..201

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

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

    func (s *State) MustSetCancelled(taskName string) {
        s.mu.Lock()
        defer s.mu.Unlock()
        if s.States[taskName] != Running {
            panic(fmt.Errorf("Current state must be Running, not %s", s.States[taskName].String()))
    Severity: Major
    Found in state.go and 4 other locations - About 45 mins to fix
    state.go on lines 134..141
    state.go on lines 149..156
    state.go on lines 179..186
    state.go on lines 194..201

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

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

    func (s *State) MustSetSuccess(taskName string) {
        s.mu.Lock()
        defer s.mu.Unlock()
        if s.States[taskName] != Running {
            panic(fmt.Errorf("Current state must be Running, not %s", s.States[taskName].String()))
    Severity: Major
    Found in state.go and 4 other locations - About 45 mins to fix
    state.go on lines 134..141
    state.go on lines 149..156
    state.go on lines 164..171
    state.go on lines 194..201

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

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

    func (s *State) MustSetFailure(taskName string) {
        s.mu.Lock()
        defer s.mu.Unlock()
        if s.States[taskName] != Running {
            panic(fmt.Errorf("Current state must be Running, not %s", s.States[taskName].String()))
    Severity: Major
    Found in state.go and 4 other locations - About 45 mins to fix
    state.go on lines 134..141
    state.go on lines 149..156
    state.go on lines 164..171
    state.go on lines 179..186

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

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

    func (t *Task) Execute(r *Recipe) error {
        t.mu.RLock()
        defer t.mu.RUnlock()
    
        if t.Cmd == "" {
    Severity: Major
    Found in task.go - About 40 mins to fix

      Method Task.Terminate has 5 return statements (exceeds 4 allowed).
      Open

      func (t *Task) Terminate() error {
          cmd := t.cmd
          if cmd == nil {
              return nil
          }
      Severity: Major
      Found in task_windows.go - About 35 mins to fix

        Method Task.Terminate has 5 return statements (exceeds 4 allowed).
        Open

        func (t *Task) Terminate() error {
            cmd := t.cmd
            if cmd == nil {
                return nil
            }
        Severity: Major
        Found in task_posix.go - About 35 mins to fix

          Method Task.composeInterpreterCmd has 5 return statements (exceeds 4 allowed).
          Open

          func (t *Task) composeInterpreterCmd(spell string, r *Recipe) []string {
              // Check task config
              if parts := t.Interpreter(); parts != nil {
                  if len(parts) == 0 {
                      return t.composeDefaultInterpreterCmd(spell)
          Severity: Major
          Found in task.go - About 35 mins to fix

            Method Recipe.validator has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
            Open

            func (r *Recipe) validator(resultCh <-chan *result, dispatchAgainCh chan<- bool, doneCh chan<- error) {
                //r.logger.Debug("Starting validator")
                for {
                    result := <-resultCh
                    if result.e != nil {
            Severity: Minor
            Found in recipe.go - About 35 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

            exported method State.MustSetFailure should have comment or be unexported
            Open

            func (s *State) MustSetFailure(taskName string) {
            Severity: Minor
            Found in state.go by golint

            exported method TaskState.MarshalJSON should have comment or be unexported
            Open

            func (s TaskState) MarshalJSON() ([]byte, error) {
            Severity: Minor
            Found in taskstate_json.go by golint

            exported method Recipe.Environ should have comment or be unexported
            Open

            func (r *Recipe) Environ() map[string]string {
            Severity: Minor
            Found in recipe.go by golint

            exported method State.SetDisabled should have comment or be unexported
            Open

            func (s *State) SetDisabled(taskName string) {
            Severity: Minor
            Found in state.go by golint

            exported method State.MustSetRunning should have comment or be unexported
            Open

            func (s *State) MustSetRunning(taskName string) {
            Severity: Minor
            Found in state.go by golint

            Multiple consecutive blank lines
            Open

            
            
            Severity: Info
            Found in README.md by markdownlint

            MD012 - Multiple consecutive blank lines

            Tags: whitespace, blank_lines

            Aliases: no-multiple-blanks

            This rule is triggered when there are multiple consecutive blank lines in the document:

            Some text here
            
            
            Some more text here

            To fix this, delete the offending lines:

            Some text here
            
            Some more text here

            Note: this rule will not be triggered if there are multiple consecutive blank lines inside code blocks.

            Severity
            Category
            Status
            Source
            Language