Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set up project to use Paratest #136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

feat: set up project to use Paratest #136

wants to merge 2 commits into from

Conversation

vitgrams
Copy link
Contributor

Done:

  • Save production doc only after all workers completed their job;
  • Added lock for tmp documentation file (for read & write as well).

@vitgrams
Copy link
Contributor Author

@DenTray Could you please review this one?

@vitgrams vitgrams self-assigned this Sep 30, 2024
rewind($handle);
fwrite($handle, json_encode($data, JSON_THROW_ON_ERROR));

flock($handle, LOCK_UN);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
flock($handle, LOCK_UN);
fclose($handle);

Comment on lines 31 to 41
$handle = @fopen($this->tempFilePath, 'r');

return json_decode($content, true);
if ($handle === false) {
return null;
}

return null;
flock($handle, LOCK_SH);

$content = stream_get_contents($handle);

return json_decode($content, true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move all low-level code to the separate function

$content = $this->getFileContentWithLock($this->tempFilePath);

return json_decode($content, true);

}

public function getTmpData(): ?array
{
if (file_exists($this->tempFilePath)) {
$content = file_get_contents($this->tempFilePath);
$handle = @fopen($this->tempFilePath, 'r');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use try catch instead

Copy link

sonarcloud bot commented Oct 25, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants