tenets:
  - name: sprintf-error
    flows:
      codelingo/rewrite:
      codelingo/docs:
        title: Sprintf Error
        body: |
          Find instances of 'errors.New(fmt.Sprintf(...))'.
      codelingo/review:
        comment: Should replace errors.New(fmt.Sprintf(...)) with errors.Errorf(...).
    query: |
      import codelingo/ast/go
  
      @review comment
      go.call_expr(depth = any):
        go.selector_expr:
          go.ident:
            name == "errors"
          @rewrite -r "Errorf"
          go.ident:
            name == "New"
        go.args:
          @rewrite -r "\"{{formatString}}\""
          go.call_expr:
            go.selector_expr:
              go.ident:
                name == "fmt"
              go.ident:
                name == "Sprintf"
            go.args:
              go.basic_lit:
                child_count == 0
                kind == "string"
                value as formatString
tenets:
  - name: sprintf-error
    vars:
      newline: |
        errors.Errorf("{{formatString}}")
    flows:
      codelingo/rewrite:
      codelingo/docs:
        title: Sprintf Error
        body: |
          Find instances of 'errors.New(fmt.Sprintf(...))'.
      codelingo/review:
        comment: Should replace errors.New(fmt.Sprintf(...)) with errors.Errorf(...).
    query: |
      import codelingo/ast/go
  
      @review comment
      @rewrite -r "{{newline}}"
      go.call_expr(depth = any):
        go.selector_expr:
          go.ident:
            name == "errors"
          go.ident:
            name == "New"
        go.args:
          go.call_expr:
            go.selector_expr:
              go.ident:
                name == "fmt"
              go.ident:
                name == "Sprintf"
            go.args:
              go.basic_lit:
                child_count == 0
                kind == "string"
                value as formatString
Add rewrite to errorf tenet.
Add rewrite to errorf tenet.
