github.com/nozzle/golangci-lint@v1.49.0-nz3/test/testdata/nosnakecase.go (about)

     1  //golangcitest:args -Enosnakecase --internal-cmd-test
     2  package testdata
     3  
     4  import (
     5  	_ "fmt"
     6  	f_m_t "fmt" // want "f_m_t contains underscore. You should use mixedCap or MixedCap."
     7  )
     8  
     9  // global variable name with underscore.
    10  var v_v = 0 // want "v_v contains underscore. You should use mixedCap or MixedCap."
    11  
    12  // global constant name with underscore.
    13  const c_c = 0 // want "c_c contains underscore. You should use mixedCap or MixedCap."
    14  
    15  // struct name with underscore.
    16  type S_a struct { // want "S_a contains underscore. You should use mixedCap or MixedCap."
    17  	fi int
    18  }
    19  
    20  // non-exported struct field name with underscore.
    21  type Sa struct {
    22  	fi_a int // // want "fi_a contains underscore. You should use mixedCap or MixedCap."
    23  }
    24  
    25  // function as struct field, with parameter name with underscore.
    26  type Sb struct {
    27  	fib func(p_a int) // want "p_a contains underscore. You should use mixedCap or MixedCap."
    28  }
    29  
    30  // exported struct field with underscore.
    31  type Sc struct {
    32  	Fi_A int // want "Fi_A contains underscore. You should use mixedCap or MixedCap."
    33  }
    34  
    35  // function as struct field, with return name with underscore.
    36  type Sd struct {
    37  	fib func(p int) (r_a int) // want "r_a contains underscore. You should use mixedCap or MixedCap."
    38  }
    39  
    40  // interface name with underscore.
    41  type I_a interface { // want "I_a contains underscore. You should use mixedCap or MixedCap."
    42  	fn(p int)
    43  }
    44  
    45  // interface with parameter name with underscore.
    46  type Ia interface {
    47  	fn(p_a int) // want "p_a contains underscore. You should use mixedCap or MixedCap."
    48  }
    49  
    50  // interface with parameter name with underscore.
    51  type Ib interface {
    52  	Fn(p_a int) // want "p_a contains underscore. You should use mixedCap or MixedCap."
    53  }
    54  
    55  // function as struct field, with return name with underscore.
    56  type Ic interface {
    57  	Fn_a() // want "Fn_a contains underscore. You should use mixedCap or MixedCap."
    58  }
    59  
    60  // interface with return name with underscore.
    61  type Id interface {
    62  	Fn() (r_a int) // want "r_a contains underscore. You should use mixedCap or MixedCap."
    63  }
    64  
    65  // function name with underscore.
    66  func f_a() {} // want "f_a contains underscore. You should use mixedCap or MixedCap."
    67  
    68  // function's parameter name with underscore.
    69  func fb(p_a int) {} // want "p_a contains underscore. You should use mixedCap or MixedCap."
    70  
    71  // named return with underscore.
    72  func fc() (r_b int) { // want "r_b contains underscore. You should use mixedCap or MixedCap."
    73  	return 0
    74  }
    75  
    76  // local variable (short declaration) with underscore.
    77  func fd(p int) int {
    78  	v_b := p * 2 // want "v_b contains underscore. You should use mixedCap or MixedCap."
    79  
    80  	return v_b // want "v_b contains underscore. You should use mixedCap or MixedCap."
    81  }
    82  
    83  // local constant with underscore.
    84  func fe(p int) int {
    85  	const v_b = 2 // want "v_b contains underscore. You should use mixedCap or MixedCap."
    86  
    87  	return v_b * p // want "v_b contains underscore. You should use mixedCap or MixedCap."
    88  }
    89  
    90  // local variable with underscore.
    91  func ff(p int) int {
    92  	var v_b = 2 // want "v_b contains underscore. You should use mixedCap or MixedCap."
    93  
    94  	return v_b * p // want "v_b contains underscore. You should use mixedCap or MixedCap."
    95  }
    96  
    97  // inner function, parameter name with underscore.
    98  func fg() {
    99  	fgl := func(p_a int) {} // want "p_a contains underscore. You should use mixedCap or MixedCap."
   100  	fgl(1)
   101  }
   102  
   103  type Foo struct{}
   104  
   105  // method name with underscore.
   106  func (f Foo) f_a() {} // want "f_a contains underscore. You should use mixedCap or MixedCap."
   107  
   108  // method's parameter name with underscore.
   109  func (f Foo) fb(p_a int) {} // want "p_a contains underscore. You should use mixedCap or MixedCap."
   110  
   111  // named return with underscore.
   112  func (f Foo) fc() (r_b int) { return 0 } // want "r_b contains underscore. You should use mixedCap or MixedCap."
   113  
   114  // local variable (short declaration) with underscore.
   115  func (f Foo) fd(p int) int {
   116  	v_b := p * 2 // want "v_b contains underscore. You should use mixedCap or MixedCap."
   117  
   118  	return v_b // want "v_b contains underscore. You should use mixedCap or MixedCap."
   119  }
   120  
   121  // local constant with underscore.
   122  func (f Foo) fe(p int) int {
   123  	const v_b = 2 // want "v_b contains underscore. You should use mixedCap or MixedCap."
   124  
   125  	return v_b * p // want "v_b contains underscore. You should use mixedCap or MixedCap."
   126  }
   127  
   128  // local variable with underscore.
   129  func (f Foo) ff(p int) int {
   130  	var v_b = 2 // want "v_b contains underscore. You should use mixedCap or MixedCap."
   131  
   132  	return v_b * p // want "v_b contains underscore. You should use mixedCap or MixedCap."
   133  }
   134  
   135  func fna(a, p_a int) {} // want "p_a contains underscore. You should use mixedCap or MixedCap."
   136  
   137  func fna1(a string, p_a int) {} // want "p_a contains underscore. You should use mixedCap or MixedCap."
   138  
   139  func fnb(a, b, p_a int) {} // want "p_a contains underscore. You should use mixedCap or MixedCap."
   140  
   141  func fnb1(a, b string, p_a int) {} // want "p_a contains underscore. You should use mixedCap or MixedCap."
   142  
   143  func fnd(
   144  	p_a int, // want "p_a contains underscore. You should use mixedCap or MixedCap."
   145  	p_b int, // want "p_b contains underscore. You should use mixedCap or MixedCap."
   146  	p_c int, // want "p_c contains underscore. You should use mixedCap or MixedCap."
   147  ) {
   148  	f_m_t.Println("") // want "f_m_t contains underscore. You should use mixedCap or MixedCap."
   149  }