<commit_before>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<commit_msg>Add rewrite to errorf tenet.<commit_after>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
{'fraction_non_alphanumeric': 0.1182741116751269, 'fraction_numerical': 0.0010152284263959391, 'mean_word_length': 1.2945285215366706, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4543846', 'n_tokens_mistral': 578, 'n_tokens_neox': 568, 'n_words': 121}