Skip to content

Commit

Permalink
Fix shadowed variable in fbpcs/emp_games/pcf2_attribution/test/Attrib…
Browse files Browse the repository at this point in the history
…utionAppTest.cpp (#2415)

Summary:
Pull Request resolved: #2415

Our upcoming compiler upgrade will require us not to have shadowed variables. Such variables have a _high_ bug rate and reduce readability, so we would like to avoid them even if the compiler was not forcing us to do so.

This codemod attempts to fix an instance of a shadowed variable. Please review with care: if it's failed the result will be a silent bug.

**What's a shadowed variable?**

Shadowed variables are variables in an inner scope with the same name as another variable in an outer scope. Having the same name for both variables might be semantically correct, but it can make the code confusing to read! It can also hide subtle bugs.

This diff fixes such an issue by renaming the variable.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: meyering

Differential Revision: D64398713

fbshipit-source-id: 869b25fb7e9d00d855b00e9b876f8c0039ab835d
  • Loading branch information
r-barnes authored and facebook-github-bot committed Oct 16, 2024
1 parent e2480e8 commit 23a0b6e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fbpcs/emp_games/pcf2_attribution/test/AttributionAppTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ class AttributionAppTest
std::string baseDir_ =
private_measurement::test_util::getBaseDirFromPath(__FILE__);
std::string tempDir = std::filesystem::temp_directory_path();
std::string outputPathAlice_ = folly::sformat(
std::string outputPathAlice_2 = folly::sformat(
"{}/output_path_alice.json_{}", tempDir, folly::Random::secureRand64());
std::string outputPathBob_ = folly::sformat(
std::string outputPathBob_2 = folly::sformat(
"{}/output_path_bob.json_{}", tempDir, folly::Random::secureRand64());

attributionRules_ = std::vector<string>{
Expand All @@ -127,8 +127,8 @@ class AttributionAppTest
std::string filePrefix = baseDir_ + "test_correctness/" + attributionRule;
inputFilenamesAlice_.push_back(filePrefix + ".publisher.csv");
inputFilenamesBob_.push_back(filePrefix + ".partner.csv");
outputFilenamesAlice_.push_back(outputPathAlice_ + attributionRule);
outputFilenamesBob_.push_back(outputPathBob_ + attributionRule);
outputFilenamesAlice_.push_back(outputPathAlice_2 + attributionRule);
outputFilenamesBob_.push_back(outputPathBob_2 + attributionRule);
expectedOutputFilenames_.push_back(filePrefix + ".json");
}
}
Expand Down

0 comments on commit 23a0b6e

Please sign in to comment.