Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
fix lint warnings (incl. in generated code)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjergus committed Aug 27, 2019
1 parent 054039b commit dfc4a26
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
20 changes: 13 additions & 7 deletions src/RequestParametersCodegenBuilder.hack
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Facebook\HackRouter;

use namespace HH\Lib\C;
use type Facebook\HackCodegen\{
CodegenClass,
CodegenShapeMember,
Expand Down Expand Up @@ -43,21 +44,26 @@ final class RequestParametersCodegenBuilder<T as RequestParametersBase>
protected function getCodegenClass(self::TSpec $spec): CodegenClass {
$param_builder = $this->parameterBuilder;
$controller = $spec['controller'];
$getParameters = $this->getParameters;
$parameters = $getParameters($controller);

$body = $this->cg->codegenHackBuilder();

$body = $this->cg
->codegenHackBuilder()
->addAssignment(
if (!C\is_empty($parameters)) {
// avoid generating an assignment to an unused variable
$body->addAssignment(
'$p',
'$this->getParameters()',
HackBuilderValues::literal(),
)
);
}

$body
->addLine('return shape(')
->indent();

$getParameters = $this->getParameters;
$param_shape = vec[];

foreach ($getParameters($controller) as $parameter) {
foreach ($parameters as $parameter) {
$param_spec = $parameter['spec'];
$request_spec = $param_builder::getRequestSpec($param_spec);
$getter_spec = $request_spec::getGetterSpec($param_spec);
Expand Down
4 changes: 2 additions & 2 deletions tests/UriMapBuilderTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class UriMapBuilderTest extends \Facebook\HackTest\HackTest {
$scanned = await FileParser::fromFileAsync(
__DIR__.'/examples/GetRequestExampleController.hack',
);
$class = $scanned->getClass(GetRequestExampleController::class);
$scanned->getClass(GetRequestExampleController::class);
$builder = $this->getBuilder($scanned);

expect($builder->getUriMap()[HttpMethod::GET]->values())->toBePHPEqual(
Expand All @@ -45,7 +45,7 @@ final class UriMapBuilderTest extends \Facebook\HackTest\HackTest {
$scanned = await FileParser::fromFileAsync(
__DIR__.'/examples/GetRequestExampleController.hack',
);
$class = $scanned->getClass(GetRequestExampleController::class);
$scanned->getClass(GetRequestExampleController::class);
$builder = $this->getBuilder($scanned);
$map = $builder->getUriMap();
expect($map->containsKey(HttpMethod::POST))->toBeFalse(
Expand Down

0 comments on commit dfc4a26

Please sign in to comment.