Skip to content

Commit

Permalink
Code cleanup for automated release builds
Browse files Browse the repository at this point in the history
Low-hanging resolutions for Code Climate
  • Loading branch information
Deltik committed Mar 28, 2020
1 parent 5eb1161 commit 07f5beb
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 275 deletions.
26 changes: 2 additions & 24 deletions .github/workflows/build-release/e107_make.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function __construct()

exec("git describe --tags", $output, $rc);
$gitVersion = array_pop($output);
$verFileVersion = self::getVerFileVersion($this->gitDir . "/e107_admin/ver.php");
$verFileVersion = OsHelper::getVerFileVersion($this->gitDir . "/e107_admin/ver.php");
$this->version = OsHelper::gitVersionToPhpVersion($gitVersion, $verFileVersion);

$this->validateReadme();
Expand All @@ -91,29 +91,7 @@ private function status($msg, $heading = false)
}
}

private static function getVerFileVersion($verFilePath)
{
$verFileTokens = token_get_all(file_get_contents($verFilePath));
$nextConstantEncapsedStringIsVersion = false;
foreach ($verFileTokens as $verFileToken)
{
if (!isset($verFileToken[1])) continue;
$token = $verFileToken[0];
$value = trim($verFileToken[1], "'\"");

if ($token === T_CONSTANT_ENCAPSED_STRING)
{
if ($nextConstantEncapsedStringIsVersion)
{
return $value;
}
if ($value === 'e107_version') $nextConstantEncapsedStringIsVersion = true;
}
}
return '0';
}

private function validateReadme()
private function validateReadme()
{
//check for readme files associated with configured releases
foreach ($this->config['releases'] as $rel)
Expand Down
Loading

0 comments on commit 07f5beb

Please sign in to comment.