Esempio n. 1
0
 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;
     }
 }
Esempio n. 2
0
 /** @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()];
 }
Esempio n. 3
0
 /** @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);
 }
Esempio n. 4
0
 /**
  * @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()]);
 }
Esempio n. 5
0
 /**
  * @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);
 }
Esempio n. 6
0
 /** @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()]);
 }
Esempio n. 7
0
 /**
  * @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);
 }
Esempio n. 8
0
 /**
  * @param IssueInstance $issue
  * @return bool
  */
 public function supports(IssueInstance $issue) : bool
 {
     return $issue->getIssue()->getSeverity() >= $this->minimumSeverity;
 }
Esempio n. 9
0
 /** @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()]]];
 }
Esempio n. 10
0
File: Issue.php Progetto: etsy/phan
 /**
  * @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);
 }
Esempio n. 11
0
 /**
  * @param IssueInstance $issue
  * @return bool
  */
 public function supports(IssueInstance $issue) : bool
 {
     return (bool) ($issue->getIssue()->getCategory() & $this->mask);
 }
Esempio n. 12
0
 /**
  * @param IssueInstance $issue
  * @return bool
  */
 public function supports(IssueInstance $issue) : bool
 {
     return !$this->ignoredFilesFilter->isFilenameIgnored($issue->getFile());
 }