Skip to content
This repository has been archived by the owner on Jan 18, 2018. It is now read-only.

Fixes json decode two times #5

Merged
merged 1 commit into from
Jan 10, 2015
Merged

Fixes json decode two times #5

merged 1 commit into from
Jan 10, 2015

Conversation

joecohens
Copy link
Member

@joecohens
Copy link
Member Author

Kicking StyleCI

@joecohens joecohens closed this Jan 10, 2015
@joecohens joecohens reopened this Jan 10, 2015
@GrahamCampbell
Copy link
Member

Errr. If the original job is still pending, styleci will just queue the next behind it. I'll check the queue processing now...

@GrahamCampbell
Copy link
Member

You seem to have crashed it...

@GrahamCampbell
Copy link
Member

@joecohens
Copy link
Member Author

Oh ok I thought it wasn't being processed.

@GrahamCampbell
Copy link
Member

I'm killing the queue worker...

@GrahamCampbell
Copy link
Member

The log is millions of lines long...

@joecohens
Copy link
Member Author

Sorry :(

@GrahamCampbell
Copy link
Member

lol, it wasn't the open close that caused it btw :)

@joecohens
Copy link
Member Author

Lol what was?

@GrahamCampbell
Copy link
Member

It seems to be the fact you've used an upper case I in the branch name.

@GrahamCampbell
Copy link
Member

One sec while I investigate...

@joecohens
Copy link
Member Author

Nice bug :)

@GrahamCampbell
Copy link
Member

lol, I'll try running git remote prune origin in the cached git repo folder...

@GrahamCampbell
Copy link
Member

errr, https://i.starbs.net/1ry2, i can't rememer which one is this repo, lol

@joecohens
Copy link
Member Author

LOL

@GrahamCampbell
Copy link
Member

It's dd22d4c7a395673687c289eeea3f34882e498f80. :)

@joecohens
Copy link
Member Author

There you go :)

@GrahamCampbell
Copy link
Member

Well that fixed it. Very odd. :/

@GrahamCampbell
Copy link
Member

@GrahamCampbell
Copy link
Member

I think I need to get styleci to just delete the cloned repo and re-clone it if we get a git error. That would probably resolve such issues.

@joecohens
Copy link
Member Author

That's weird so it wasn't the upper case?

@joecohens
Copy link
Member Author

Yeah that would be cool, like a retry.

@@ -140,11 +140,11 @@ protected function parseResponse($body)
*/
protected function responseError($rawResponse)
{
if (! $this->isJson($rawResponse->getBody())) {
return $this->jsonError($rawResponse);
if ($json = $this->isJson($rawResponse->getBody())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asignment inside if statements is generally regarded as bad. Symfony doesn't allow it for example.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know :)

$json = $this->isJson($rawResponse->getBody())

return $json ?: $this->jsonError($rawResponse);

Better?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do that, you could actually just do a one liner.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done return $this->isJson($rawResponse->getBody()) ?: $this->jsonError($rawResponse);

@GrahamCampbell
Copy link
Member

That's weird so it wasn't the upper case?

No, I don't think it was. I have no idea what caused this.

@joecohens joecohens force-pushed the fix/Inefficiency branch 2 times, most recently from 5bc672d to 0d94cf9 Compare January 10, 2015 18:53
@@ -193,13 +189,17 @@ public function jsonError($rawResponse)
*
* @param string $string
*
* @return bool
* @return bool|array
*/
protected function isJson($string)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isJson isn't really the correct method name now

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right it's not returning a bool only anymore.. validateJson() or isValidJson?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getJson() would be better surely?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and doesn't json_decode return null on error anyway, so this entire method is a bit over kill

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol yeah!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed completely :)

@@ -167,13 +163,17 @@ public function jsonError($rawResponse)
*
* @param string $string
*
* @return bool
* @return bool|array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

array|bool would be better :)

@joecohens
Copy link
Member Author

Done. Merging this thank you very much sir! :)

joecohens added a commit that referenced this pull request Jan 10, 2015
@joecohens joecohens merged commit eeff94e into master Jan 10, 2015
@joecohens joecohens deleted the fix/Inefficiency branch January 10, 2015 19:11
@GrahamCampbell
Copy link
Member

:)

@GrahamCampbell
Copy link
Member

I'm working on creating a decorator for the repository class in styleci fixer that will re-entry stuff and delete the repo if it's damaged ect.

@joecohens
Copy link
Member Author

Awesome!!!!

@GrahamCampbell
Copy link
Member

I think we might even need to move this stuff to a new package. It's getting quite large now...

@GrahamCampbell
Copy link
Member

Namespaces are properly massive now, lol: https://i.starbs.net/AW67.

@joecohens
Copy link
Member Author

LOL really massive and hard to write :)

@GrahamCampbell
Copy link
Member

Hmm. I'm going to drop "Failed" from the exception names. I'm also going to move the "StyleCI\Fixer\Git" namespace to "StyleCI\Git" at a later point too. :)

@joecohens
Copy link
Member Author

👍 Yeah I like it better.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
2 participants