Skip to content

Commit 7242b89

Browse files
mridangclaude
andcommitted
fix: correct line length and formatting violations in Ruby and PHP templates
Ruby: all 7 HTTP error class templates generated a single-line super() call that was 136 chars, exceeding RuboCop's 120-char limit. Expand the hash arguments onto individual lines so every line stays under 120 chars. PHP: BaseApiTest.mustache generated multi-line function calls with multiple arguments per line and inline braces, causing ~120 PHPCS violations (PSR-12 requires one arg per line and Allman-style braces). Expand all invokeApi/call() sites to one-arg-per-line, fix the empty constructor body, and expand one-liner interface methods. value_serializer.mustache had a blank line before the class closing brace that PHPCS flagged; remove it. All 46 integration tests now pass cleanly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1936d06 commit 7242b89

9 files changed

Lines changed: 190 additions & 39 deletions

src/main/resources/templates/php/test/BaseApiTest.mustache

Lines changed: 141 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,16 @@ class TestableApi extends BaseApi
4040
?Authenticator $auth = null
4141
): mixed {
4242
return $this->invokeApi(
43-
$method, $path, $queryParams, $headerParams, $body,
44-
$accepts, $contentType, $returnType, $auth);
43+
$method,
44+
$path,
45+
$queryParams,
46+
$headerParams,
47+
$body,
48+
$accepts,
49+
$contentType,
50+
$returnType,
51+
$auth
52+
);
4553
}
4654
}
4755

@@ -56,12 +64,28 @@ class TestAuthenticator implements Authenticator
5664
private readonly array $headers = [],
5765
private readonly array $queryParams = [],
5866
private readonly array $cookies = []
59-
) {}
67+
) {
68+
}
69+
70+
public function getHost(): string
71+
{
72+
return '';
73+
}
74+
75+
public function getAuthHeaders(): array
76+
{
77+
return $this->headers;
78+
}
79+
80+
public function getQueryParams(): array
81+
{
82+
return $this->queryParams;
83+
}
6084

61-
public function getHost(): string { return ''; }
62-
public function getAuthHeaders(): array { return $this->headers; }
63-
public function getQueryParams(): array { return $this->queryParams; }
64-
public function getCookieParams(): array { return $this->cookies; }
85+
public function getCookieParams(): array
86+
{
87+
return $this->cookies;
88+
}
6589
}
6690

6791
class BaseApiTest extends TestCase
@@ -97,8 +121,15 @@ class BaseApiTest extends TestCase
97121
{
98122
try {
99123
$this->api()->call(
100-
'GET', "/api/error/$status", [], [], null,
101-
['application/json'], 'application/json', null);
124+
'GET',
125+
"/api/error/$status",
126+
[],
127+
[],
128+
null,
129+
['application/json'],
130+
'application/json',
131+
null
132+
);
102133
$this->fail('Expected exception not thrown');
103134
} catch (ApiException $e) {
104135
$this->assertInstanceOf($expectedClass, $e);
@@ -111,8 +142,15 @@ class BaseApiTest extends TestCase
111142
{
112143
try {
113144
$this->api()->call(
114-
'GET', '/api/error/404', [], [], null,
115-
['application/json'], 'application/json', null);
145+
'GET',
146+
'/api/error/404',
147+
[],
148+
[],
149+
null,
150+
['application/json'],
151+
'application/json',
152+
null
153+
);
116154
$this->fail('Expected exception not thrown');
117155
} catch (NotFoundException $e) {
118156
$this->assertInstanceOf(ClientException::class, $e);
@@ -124,8 +162,15 @@ class BaseApiTest extends TestCase
124162
{
125163
try {
126164
$this->api()->call(
127-
'GET', '/api/error/500', [], [], null,
128-
['application/json'], 'application/json', null);
165+
'GET',
166+
'/api/error/500',
167+
[],
168+
[],
169+
null,
170+
['application/json'],
171+
'application/json',
172+
null
173+
);
129174
$this->fail('Expected exception not thrown');
130175
} catch (InternalServerErrorException $e) {
131176
$this->assertInstanceOf(ServerException::class, $e);
@@ -136,43 +181,79 @@ class BaseApiTest extends TestCase
136181
public function testDeserializesJsonResponse(): void
137182
{
138183
$result = $this->api()->call(
139-
'GET', '/api/test', [], [], null,
140-
['application/json'], 'application/json', 'array');
184+
'GET',
185+
'/api/test',
186+
[],
187+
[],
188+
null,
189+
['application/json'],
190+
'application/json',
191+
'array'
192+
);
141193
$this->assertIsArray($result);
142194
$this->assertSame('success', $result['message']);
143195
}
144196

145197
public function testReturnsRawStringForNonJson(): void
146198
{
147199
$result = $this->api()->call(
148-
'GET', '/api/text', [], [], null,
149-
['text/plain'], 'application/json', 'string');
200+
'GET',
201+
'/api/text',
202+
[],
203+
[],
204+
null,
205+
['text/plain'],
206+
'application/json',
207+
'string'
208+
);
150209
$this->assertIsString($result);
151210
$this->assertStringContainsString('hello plain text', $result);
152211
}
153212

154213
public function testReturnsNullWhenReturnTypeIsNull(): void
155214
{
156215
$result = $this->api()->call(
157-
'GET', '/api/test', [], [], null,
158-
['application/json'], 'application/json', null);
216+
'GET',
217+
'/api/test',
218+
[],
219+
[],
220+
null,
221+
['application/json'],
222+
'application/json',
223+
null
224+
);
159225
$this->assertNull($result);
160226
}
161227

162228
public function testAppendsQueryParams(): void
163229
{
164230
$result = $this->api()->call(
165-
'GET', '/api/test', ['foo' => 'bar'], [], null,
166-
['application/json'], 'application/json', null);
231+
'GET',
232+
'/api/test',
233+
['foo' => 'bar'],
234+
[],
235+
null,
236+
['application/json'],
237+
'application/json',
238+
null
239+
);
167240
$this->assertNull($result);
168241
}
169242

170243
public function testForwardsAuthHeaders(): void
171244
{
172245
$auth = new TestAuthenticator(headers: ['X-Custom' => 'auth-value']);
173246
$result = $this->api()->call(
174-
'GET', '/api/echo-headers', [], [], null,
175-
['application/json'], 'application/json', 'array', $auth);
247+
'GET',
248+
'/api/echo-headers',
249+
[],
250+
[],
251+
null,
252+
['application/json'],
253+
'application/json',
254+
'array',
255+
$auth
256+
);
176257
$this->assertIsArray($result);
177258
$this->assertSame('auth-value', $result['x-custom']);
178259
}
@@ -181,33 +262,62 @@ class BaseApiTest extends TestCase
181262
{
182263
$auth = new TestAuthenticator(cookies: ['session' => 'abc123']);
183264
$this->api()->call(
184-
'GET', '/api/test', [], [], null,
185-
['application/json'], 'application/json', null, $auth);
265+
'GET',
266+
'/api/test',
267+
[],
268+
[],
269+
null,
270+
['application/json'],
271+
'application/json',
272+
null,
273+
$auth
274+
);
186275
$this->addToAssertionCount(1);
187276
}
188277

189278
public function testSerializesJsonBody(): void
190279
{
191280
$result = $this->api()->call(
192-
'POST', '/api/echo-body', [], [], ['key' => 'value'],
193-
['application/json'], 'application/json', 'array');
281+
'POST',
282+
'/api/echo-body',
283+
[],
284+
[],
285+
['key' => 'value'],
286+
['application/json'],
287+
'application/json',
288+
'array'
289+
);
194290
$this->assertIsArray($result);
195291
$this->assertSame('value', $result['key']);
196292
}
197293

198294
public function testSendsNoBodyWhenNull(): void
199295
{
200296
$this->api()->call(
201-
'GET', '/api/test', [], [], null,
202-
['application/json'], 'application/json', null);
297+
'GET',
298+
'/api/test',
299+
[],
300+
[],
301+
null,
302+
['application/json'],
303+
'application/json',
304+
null
305+
);
203306
$this->addToAssertionCount(1);
204307
}
205308

206309
public function testAllowEmptyValueIncludesParamInQueryString(): void
207310
{
208311
$result = $this->api()->call(
209-
'GET', '/api/test', ['filter' => ''], [], null,
210-
['application/json'], 'application/json', null);
312+
'GET',
313+
'/api/test',
314+
['filter' => ''],
315+
[],
316+
null,
317+
['application/json'],
318+
'application/json',
319+
null
320+
);
211321
$this->assertNull($result);
212322
}
213323

src/main/resources/templates/php/value_serializer.mustache

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,4 @@ final class ValueSerializer
179179

180180
return $result;
181181
}
182-
183182
}

src/main/resources/templates/ruby/errors/bad_request_error.mustache

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ module {{moduleName}}
66
# Exception for HTTP 400 Bad Request.
77
class BadRequestError < ClientError
88
def initialize(message: nil, response_body: nil, response_headers: nil, error_body: nil)
9-
super({ code: 400, message: message, response_body: response_body, response_headers: response_headers, error_body: error_body })
9+
super({
10+
code: 400,
11+
message: message,
12+
response_body: response_body,
13+
response_headers: response_headers,
14+
error_body: error_body
15+
})
1016
end
1117
end
1218
end

src/main/resources/templates/ruby/errors/conflict_error.mustache

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ module {{moduleName}}
66
# Exception for HTTP 409 Conflict.
77
class ConflictError < ClientError
88
def initialize(message: nil, response_body: nil, response_headers: nil, error_body: nil)
9-
super({ code: 409, message: message, response_body: response_body, response_headers: response_headers, error_body: error_body })
9+
super({
10+
code: 409,
11+
message: message,
12+
response_body: response_body,
13+
response_headers: response_headers,
14+
error_body: error_body
15+
})
1016
end
1117
end
1218
end

src/main/resources/templates/ruby/errors/forbidden_error.mustache

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ module {{moduleName}}
66
# Exception for HTTP 403 Forbidden.
77
class ForbiddenError < ClientError
88
def initialize(message: nil, response_body: nil, response_headers: nil, error_body: nil)
9-
super({ code: 403, message: message, response_body: response_body, response_headers: response_headers, error_body: error_body })
9+
super({
10+
code: 403,
11+
message: message,
12+
response_body: response_body,
13+
response_headers: response_headers,
14+
error_body: error_body
15+
})
1016
end
1117
end
1218
end

src/main/resources/templates/ruby/errors/internal_server_error.mustache

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ module {{moduleName}}
66
# Exception for HTTP 500 Internal Server Error.
77
class InternalServerError < ServerError
88
def initialize(message: nil, response_body: nil, response_headers: nil, error_body: nil)
9-
super({ code: 500, message: message, response_body: response_body, response_headers: response_headers, error_body: error_body })
9+
super({
10+
code: 500,
11+
message: message,
12+
response_body: response_body,
13+
response_headers: response_headers,
14+
error_body: error_body
15+
})
1016
end
1117
end
1218
end

src/main/resources/templates/ruby/errors/not_found_error.mustache

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ module {{moduleName}}
66
# Exception for HTTP 404 Not Found.
77
class NotFoundError < ClientError
88
def initialize(message: nil, response_body: nil, response_headers: nil, error_body: nil)
9-
super({ code: 404, message: message, response_body: response_body, response_headers: response_headers, error_body: error_body })
9+
super({
10+
code: 404,
11+
message: message,
12+
response_body: response_body,
13+
response_headers: response_headers,
14+
error_body: error_body
15+
})
1016
end
1117
end
1218
end

src/main/resources/templates/ruby/errors/unauthorized_error.mustache

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ module {{moduleName}}
66
# Exception for HTTP 401 Unauthorized.
77
class UnauthorizedError < ClientError
88
def initialize(message: nil, response_body: nil, response_headers: nil, error_body: nil)
9-
super({ code: 401, message: message, response_body: response_body, response_headers: response_headers, error_body: error_body })
9+
super({
10+
code: 401,
11+
message: message,
12+
response_body: response_body,
13+
response_headers: response_headers,
14+
error_body: error_body
15+
})
1016
end
1117
end
1218
end

src/main/resources/templates/ruby/errors/unprocessable_entity_error.mustache

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ module {{moduleName}}
66
# Exception for HTTP 422 Unprocessable Entity.
77
class UnprocessableEntityError < ClientError
88
def initialize(message: nil, response_body: nil, response_headers: nil, error_body: nil)
9-
super({ code: 422, message: message, response_body: response_body, response_headers: response_headers, error_body: error_body })
9+
super({
10+
code: 422,
11+
message: message,
12+
response_body: response_body,
13+
response_headers: response_headers,
14+
error_body: error_body
15+
})
1016
end
1117
end
1218
end

0 commit comments

Comments
 (0)