public static function get_severity_code(IssueInstance $instance) : string { $issue = $instance->getIssue(); $categoryId = $issue->getTypeId(); switch ($issue->getSeverity()) { case Issue::SEVERITY_LOW: return 'C' . $categoryId; case Issue::SEVERITY_NORMAL: return 'W' . $categoryId; case Issue::SEVERITY_CRITICAL: return 'E' . $categoryId; } }
/** @param IssueInstance $instance */ public function print(IssueInstance $instance) { if (empty($this->files[$instance->getFile()])) { $this->files[$instance->getFile()] = []; } // Group issues by file $this->files[$instance->getFile()][] = ['line' => $instance->getLine(), 'source' => $instance->getIssue()->getType(), 'message' => $instance->getMessage(), 'severity' => $instance->getIssue()->getSeverityName()]; }
/** @param IssueInstance $instance */ public function print(IssueInstance $instance) { $issue = sprintf('%s:%d %s %s', $instance->getFile(), $instance->getLine(), $instance->getIssue()->getType(), $instance->getMessage()); $this->output->writeln($issue); }
/** * @param IssueInstance $issue * @return string */ private function formatSortableKey(IssueInstance $issue) { // This needs to be a sortable key so that output // is in the expected order return implode('|', [$issue->getFile(), str_pad((string) $issue->getLine(), 5, '0', STR_PAD_LEFT), $issue->getIssue()->getType(), $issue->getMessage()]); }
/** * @param CodeBase $code_base * The code base within which we're operating * * @param Context $context * The context in which the instance was found * * @param IssueInstance $issue_instance * An issue instance to emit * * @return void */ public static function maybeEmitInstance(CodeBase $code_base, Context $context, IssueInstance $issue_instance) { // If this issue type has been suppressed in // the config, ignore it if (in_array($issue_instance->getIssue()->getType(), Config::get()->suppress_issue_types ?? [])) { return; } // If this issue type has been suppressed in // this scope from a doc block, ignore it. if ($context->hasSuppressIssue($code_base, $issue_instance->getIssue()->getType())) { return; } self::emitInstance($issue_instance); }
/** @param IssueInstance $instance */ public function print(IssueInstance $instance) { fputcsv($this->stream, [$instance->getFile(), $instance->getLine(), $instance->getIssue()->getSeverity(), $instance->getIssue()->getSeverityName(), Issue::getNameForCategory($instance->getIssue()->getCategory()), $instance->getIssue()->getType(), $instance->getMessage()]); }
/** * @param CodeBase $code_base * The code base within which we're operating * * @param Context $context * The context in which the instance was found * * @param IssueInstance $issue_instance * An issue instance to emit * * @return void */ public static function maybeEmitInstance(CodeBase $code_base, Context $context, IssueInstance $issue_instance) { if ($context->hasSuppressIssue($code_base, $issue_instance->getIssue()->getType())) { return; } self::emitInstance($issue_instance); }
/** * @param IssueInstance $issue * @return bool */ public function supports(IssueInstance $issue) : bool { return $issue->getIssue()->getSeverity() >= $this->minimumSeverity; }
/** @param IssueInstance $instance */ public function print(IssueInstance $instance) { $this->messages[] = ['type' => 'issue', 'check_name' => $instance->getIssue()->getType(), 'description' => Issue::getNameForCategory($instance->getIssue()->getCategory()) . ' ' . $instance->getIssue()->getType() . ' ' . $instance->getMessage(), 'categories' => ['Bug Risk'], 'severity' => self::mapSeverity($instance->getIssue()->getSeverity()), 'location' => ['path' => preg_replace('/^\\/code\\//', '', $instance->getFile()), 'lines' => ['begin' => $instance->getLine(), 'end' => $instance->getLine()]]]; }
/** * @param CodeBase $code_base * The code base within which we're operating * * @param Context $context * The context in which the instance was found * * @param IssueInstance $issue_instance * An issue instance to emit * * @return void */ public static function maybeEmitInstance(CodeBase $code_base, Context $context, IssueInstance $issue_instance) { // If this issue type has been suppressed in // the config, ignore it if (!Config::get()->disable_suppression && in_array($issue_instance->getIssue()->getType(), Config::get()->suppress_issue_types ?? [])) { return; } // If a white-list of allowed issue types is defined, // only emit issues on the white-list if (!Config::get()->disable_suppression && count(Config::get()->whitelist_issue_types) > 0 && !in_array($issue_instance->getIssue()->getType(), Config::get()->whitelist_issue_types ?? [])) { return; } // If this issue type has been suppressed in // this scope from a doc block, ignore it. if (!Config::get()->disable_suppression && $context->hasSuppressIssue($code_base, $issue_instance->getIssue()->getType())) { return; } self::emitInstance($issue_instance); }
/** * @param IssueInstance $issue * @return bool */ public function supports(IssueInstance $issue) : bool { return (bool) ($issue->getIssue()->getCategory() & $this->mask); }
/** * @param IssueInstance $issue * @return bool */ public function supports(IssueInstance $issue) : bool { return !$this->ignoredFilesFilter->isFilenameIgnored($issue->getFile()); }