Kerrigan29a/recipe

View on GitHub
recipe.go

Summary

Maintainability
A
2 hrs
Test Coverage

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

    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

    TODO found
    Open

            // TODO: Implement a modeline mechanism? // -*- coding: utf-8; mode: json; -*-
    Severity: Minor
    Found in recipe.go by fixme

    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

    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 Recipe.RunTask should have comment or be unexported
    Open

    func (r *Recipe) RunTask(task string, numWorkers uint) error {
    Severity: Minor
    Found in recipe.go by golint

    exported type Error should have comment or be unexported
    Open

    type Error struct {
    Severity: Minor
    Found in recipe.go by golint

    exported type Recipe should have comment or be unexported
    Open

    type Recipe struct {
    Severity: Minor
    Found in recipe.go by golint

    exported function Open should have comment or be unexported
    Open

    func Open(path string, recipeLogger, stateLogger *Logger) (*Recipe, error) {
    Severity: Minor
    Found in recipe.go by golint

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

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

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

    func (r *Recipe) PrettyString() string {
    Severity: Minor
    Found in recipe.go by golint

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

    func (r *Recipe) RunMain(numWorkers uint) error {
    Severity: Minor
    Found in recipe.go by golint

    exported type TaskIterator should have comment or be unexported
    Open

    type TaskIterator struct {
    Severity: Minor
    Found in recipe.go by golint

    There are no issues that match your filters.

    Category
    Status