-
Notifications
You must be signed in to change notification settings - Fork 44
Start to work on generic issue reporters #235
base: master
Are you sure you want to change the base?
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 |
src/Report/JsonReporter.php
Outdated
@@ -0,0 +1,38 @@ | |||
<?php | |||
|
|||
namespace PHPSA\Report; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should put Report inside Analyzer directory
And seems Issue's classes to this dir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but syntax error issues belong to compiler not analyzer
src/Compiler/Expression/Assign.php
Outdated
continue; | ||
} | ||
|
||
$symbol = $context->getSymbol($var->name); | ||
if (!$symbol) { | ||
$symbol = new \PHPSA\Variable( | ||
$symbol = new \PhpSA\Variable( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even though it works I think we should stick to PHPSA all uppercase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHPSA should be in uppercase
Because it's abbreviation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep 👍
This modification wasn't intended.
return $output . "\n"; | ||
} | ||
|
||
private function formatNotice(Issue $issue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 :)
@@ -130,6 +132,7 @@ public function toArray() | |||
'description' => $this->description, | |||
'location' => $this->location->toArray(), | |||
'categories' => $this->categories, | |||
'blame' => $this->blame, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not needed there, toArray is a special method for CodeClimate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
@@ -59,17 +60,22 @@ class Variable | |||
*/ | |||
protected $type; | |||
|
|||
/** @var NodeAbstract The AST node where the variable is declared */ | |||
protected $declarationStmt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not Needed
$json = json_encode($issue->toArray()); | ||
|
||
if (!$this->isFirstIssue) { | ||
$json = ', '.$json; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to use format as CodeClimate
echo $json . chr(0);
src/Context.php
Outdated
* @param string|null $filepath | ||
* @return bool | ||
*/ | ||
protected function addIssue($type, $message, $line, $filepath = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IssueLocation in near feature will be different and will support blocks
and half of line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the method definition to use an IssueLocation
object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@K-Phoen But how to pass category? Myabe lets use Issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or another way to split methods like
->styleNotice
->securityNotice
->performanceNotice
m?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep yep, done (I didn't see your previous comment before updating the code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
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