<commit_before>funcs:
  - name: isInvalidErrName
    type: asserter
    body: |
      function (a) {
        var dot = a.charAt(a.length - 1) === '.'
        var cap = a.charAt(0) >= "A" && a.charAt(0) <= "Z"
        return dot || cap
      }
  - name: fixErrorFormat
    type: resolver
    body: |
      function(text) {
        function escapeGoFormat(text) {
          return text.replace(new RegExp("([\\\"])", "g"), "\\$1")
        }
        
        function surroundWithQuotes(text) {
          return "\"" + text + "\""
        }
        
        function uncapitalizeFirstLetter(text) {
          return text.charAt(0).toLowerCase() + text.slice(1);
        }

        return surroundWithQuotes(escapeGoFormat(uncapitalizeFirstLetter(text)))
      }
tenets:
  - name: go-error-fmt
    flows:
      codelingo/rewrite:
      codelingo/docs:
        title: Go Error Format
        body: |
          Error strings should not be capitalized (unless beginning with proper nouns 
          or acronyms) or end with punctuation, since they are usually printed following
          other context. That is, use fmt.Errorf("something bad") not fmt.Errorf("Something bad"),
          so that log.Printf("Reading %s: %v", filename, err) formats without a spurious 
          capital letter mid-message. This does not apply to logging, which is implicitly
          line-oriented and not combined inside other messages.
      codelingo/review:
        comment: |
          Error strings should not be capitalized (unless beginning with proper nouns 
          or acronyms) or end with punctuation, since they are usually printed following
          other context.
    query: |
      import codelingo/ast/go
<commit_msg>Extend tenet to remove trailing punctuation from error strings<commit_after>funcs:
  - name: isInvalidErrName
    type: asserter
    body: |
      function (a) {
        var dot = a.charAt(a.length - 1) === '.'
        var cap = a.charAt(0) >= "A" && a.charAt(0) <= "Z"
        return dot || cap
      }
  - name: fixErrorFormat
    type: resolver
    body: |
      function(text) {
        function escapeGoFormat(text) {
          return text.replace(new RegExp("([\\\"])", "g"), "\\$1")
        }
        
        function surroundWithQuotes(text) {
          return "\"" + text + "\""
        }
        
        function uncapitalizeFirstLetter(text) {
          return text.charAt(0).toLowerCase() + text.slice(1);
        }

        function removeTrailingPunctuation(text) {
          var re = /[.;:!? ]/
          while (re.exec(text.charAt(text.length - 1))) {
            text = text.substring(0, text.length - 1)
          }
          return text
        }

        return surroundWithQuotes(escapeGoFormat(uncapitalizeFirstLetter(removeTrailingPunctuation(text))))
      }
tenets:
  - name: go-error-fmt
    flows:
      codelingo/rewrite:
      codelingo/docs:
        title: Go Error Format
        body: |
          Error strings should not be capitalized (unless beginning with proper nouns 
          or acronyms) or end with punctuation, since they are usually printed following
          other context. That is, use fmt.Errorf("something bad") not fmt.Errorf("Something bad"),
          so that log.Printf("Reading %s: %v", filename, err) formats without a spurious 
          capital letter mid-message. This does not apply to logging, which is implicitly
          line-oriented and not combined inside other messages.
      codelingo/review:
        comment: |
          Error strings should not be capitalized (unless beginning with proper nouns 
          or acronyms) or end with punctuation, since they are usually printed following
          other context.
    query: |
      import codelingo/ast/go

{'fraction_non_alphanumeric': 0.10133689839572192, 'fraction_numerical': 0.004010695187165776, 'mean_word_length': 2.1357921207041075, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '15880', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1042, 'n_words': 319}