Start to work on generic issue reporters#235
Conversation
|
I assigned you to issue #18 then. It's HTML output. For start it would be enough to just wrap it in some html tags, the styling can be done later |
| @@ -0,0 +1,38 @@ | |||
| <?php | |||
|
|
|||
| namespace PHPSA\Report; | |||
There was a problem hiding this comment.
We should put Report inside Analyzer directory
And seems Issue's classes to this dir
There was a problem hiding this comment.
but syntax error issues belong to compiler not analyzer
| $symbol = $context->getSymbol($var->name); | ||
| if (!$symbol) { | ||
| $symbol = new \PHPSA\Variable( | ||
| $symbol = new \PhpSA\Variable( |
There was a problem hiding this comment.
even though it works I think we should stick to PHPSA all uppercase?
There was a problem hiding this comment.
PHPSA should be in uppercase
Because it's abbreviation
There was a problem hiding this comment.
Yep 👍
This modification wasn't intended.
| return $output . "\n"; | ||
| } | ||
|
|
||
| private function formatNotice(Issue $issue) |
There was a problem hiding this comment.
Can't we change that to:
Filename
line: issue 1 [checkname]
code of issue 1
line: issue 2 [checkname]
code of issue 2
next Filename
...
Also we want to add language level errors 👍
There was a problem hiding this comment.
In this PR, I'll only provide the architecture to write different outputs. We'll be able to add new or update existing ones later :)
| 'description' => $this->description, | ||
| 'location' => $this->location->toArray(), | ||
| 'categories' => $this->categories, | ||
| 'blame' => $this->blame, |
There was a problem hiding this comment.
It's not needed there, toArray is a special method for CodeClimate
There was a problem hiding this comment.
Having a method that is specific for CodeClimate in a class that's not specific is a bit weird I think.
Moreover, shouldn't we implement CodeClimate as another output format?
| protected $type; | ||
|
|
||
| /** @var NodeAbstract The AST node where the variable is declared */ | ||
| protected $declarationStmt; |
| $json = json_encode($issue->toArray()); | ||
|
|
||
| if (!$this->isFirstIssue) { | ||
| $json = ', '.$json; |
There was a problem hiding this comment.
I suggest to use format as CodeClimate
echo $json . chr(0);
| * @param string|null $filepath | ||
| * @return bool | ||
| */ | ||
| protected function addIssue($type, $message, $line, $filepath = null) |
There was a problem hiding this comment.
IssueLocation in near feature will be different and will support blocks
and half of line
There was a problem hiding this comment.
There was a problem hiding this comment.
Btw, I suggest to pass Issue, because this will be rly hard to pass 100500 parameters to customize Issue
For example cutegories, IssueLocation
There was a problem hiding this comment.
I updated the method definition to use an IssueLocation object.
There was a problem hiding this comment.
@K-Phoen But how to pass category? Myabe lets use Issue?
There was a problem hiding this comment.
Or another way to split methods like
->styleNotice
->securityNotice
->performanceNotice
m?
There was a problem hiding this comment.
Yep yep, done (I didn't see your previous comment before updating the code).
There was a problem hiding this comment.
The Context class already has too many methods/responsibilities. I just wanted to initiate a bit of cleaning :)
There was a problem hiding this comment.
but anyway main question how pass categories? Lets add a parameter with default value to notice method, will be helpfull to pass normal category or categories of the Issue
And for errorLanguage lets pass Issue::CATEGORY_BUG_RISK to Issue
b9d125e to
de8145a
Compare
|
@ovr If that sounds good to you, I think that I will modify the codeclimate-related code to be just another output format. I'll create an issue for that and do it in a separate PR. Also, I think that the WDYT? |
Hey!
Type: new feature
Link to issue:
This pull request affects the following components (please check boxes):
In raising this pull request, I confirm the following (please check boxes):
Small description of change:
This PR starts to make the output generation generic. We should be able to generate several output formats depending on what the user wants (xml, json, text, …).
For now, I only introduced a generic way to transform issues to JSON/XML, other. In future commits, I'll work on a solution to combine several outputs, manage IO, etc.
Thanks