Skip to content

Commit

Permalink
Upd. Code. Get changes from SPBCT.
Browse files Browse the repository at this point in the history
  • Loading branch information
Glomberg committed Jun 25, 2024
1 parent 58029bf commit c16465d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
12 changes: 8 additions & 4 deletions HeuristicAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function __construct($input, $self = null)
$this->path = $input['path'];
$this->curr_dir = dirname($this->path);
$this->extension = pathinfo($this->path, PATHINFO_EXTENSION);
$this->checkFileSize(filesize($this->path));
$this->checkFileSize((int)filesize($this->path));
$this->checkFileAccessibility();
$this->file_size = (int)filesize($this->path);
$this->file_work = file_get_contents($this->path);
Expand Down Expand Up @@ -287,9 +287,13 @@ public function processContent()
// Analysing code style
// Do this, only for initial code
if ( ! $this->evaluations->evaluations ) {
if ( $this->extension !== 'html' && $this->extension !== 'js' ) {
//todo turn this back after task finished https://doboard.com/1/task/6692
//$this->code_style->analyseLineLengths($this->file_content);
if (
$this->extension !== 'html' &&
$this->extension !== 'htm' &&
$this->extension !== 'shtml' &&
$this->extension !== 'js'
) {
$this->code_style->analyseLineLengths($this->file_content);
$this->code_style->analyseHumanUnreadableCode($this->file_content);
$this->code_style->analyseWeightOfNoise($this->file_content);
}
Expand Down
7 changes: 4 additions & 3 deletions Modules/CodeStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function analyseLineLengths(&$content)
for ( $line_num = 1; isset($lines[$line_num - 1]); $line_num++ ) {
try {
$line = $lines[$line_num - 1];
if ($this->analyseLineLengthsIsExceptions($line)) {
if ($this->analyseLineLengthsIsExcludedForLine($line)) {
continue;
}
if ( strlen($line) > self::CRITICAL_CODE_STRING_LENGTH ) {
Expand All @@ -145,12 +145,13 @@ public function analyseLineLengths(&$content)
}

/**
* Check exceptions for long line
* Check if the line should be skipped.
* Uses regexps of known signs to exclude.
*
* @param string $line
* @return bool
*/
public function analyseLineLengthsIsExceptions($line)
public function analyseLineLengthsIsExcludedForLine($line)
{
if (preg_match('#^\s*<path\s+d="[^$][.\w\s-]+"\s*\/>#', $line, $match)) {
return true;
Expand Down

0 comments on commit c16465d

Please sign in to comment.