Fix bugs reported by scrutinizer

This commit is contained in:
Stéphane Goetz 2016-07-29 22:38:03 +02:00
parent fb5fb41e96
commit 948f2aaa39
12 changed files with 66 additions and 48 deletions

View File

@ -77,8 +77,10 @@ function createLinter() {
var style_tasks = []; var style_tasks = [];
for (var style in resources) { for (var style in resources) {
if (resources.hasOwnProperty(style)) {
gulp.task('style_' + style, createTask(resources[style].source, resources[style].dest)); gulp.task('style_' + style, createTask(resources[style].source, resources[style].dest));
style_tasks.push('style_' + style); style_tasks.push('style_' + style);
}
} }
gulp.task('lint-css', createLinter); gulp.task('lint-css', createLinter);

View File

@ -357,7 +357,7 @@ class Daux
*/ */
public function getContentExtensions() public function getContentExtensions()
{ {
if ($this->validExtensions) { if (!empty($this->validExtensions)) {
return $this->validExtensions; return $this->validExtensions;
} }

View File

@ -2,6 +2,7 @@
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\Exception\BadResponseException; use GuzzleHttp\Exception\BadResponseException;
use GuzzleHttp\Exception\RequestException;
class Api class Api
{ {
@ -42,7 +43,7 @@ class Api
* this will give little bit more sense to it and return it * this will give little bit more sense to it and return it
* *
* @param BadResponseException $e * @param BadResponseException $e
* @return BadResponseException * @return RequestException
*/ */
protected function handleError(BadResponseException $e) protected function handleError(BadResponseException $e)
{ {

View File

@ -15,6 +15,10 @@ class ImageRenderer extends \League\CommonMark\Inline\Renderer\ImageRenderer
*/ */
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer) public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
{ {
if (!($inline instanceof Image)) {
throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
}
// External Images need special handling // External Images need special handling
if (strpos($inline->getUrl(), 'http') === 0) { if (strpos($inline->getUrl(), 'http') === 0) {
return new HtmlElement( return new HtmlElement(

View File

@ -1,5 +1,5 @@
<?php namespace Todaymade\Daux\Format\Confluence; <?php namespace Todaymade\Daux\Format\Confluence;
class DuplicateTitleException extends \RuntimeException class DuplicateTitleException extends \GuzzleHttp\Exception\RequestException
{ {
} }

View File

@ -164,9 +164,12 @@ class Processor implements DocumentProcessorInterface
$a = new Link('#' . $entry->getId()); $a = new Link('#' . $entry->getId());
$children = $entry->getChildren();
if ($children != null) {
foreach ($this->cloneChildren($entry->getContent()) as $node) { foreach ($this->cloneChildren($entry->getContent()) as $node) {
$a->appendChild($node); $a->appendChild($node);
} }
}
$p = new Paragraph(); $p = new Paragraph();
$p->appendChild($a); $p->appendChild($a);

View File

@ -167,7 +167,7 @@ class Builder
/** /**
* @param Directory $parent * @param Directory $parent
* @param string $path * @param string $path
* @return Content * @return ContentAbstract
*/ */
public static function getOrCreatePage(Directory $parent, $path) public static function getOrCreatePage(Directory $parent, $path)
{ {

View File

@ -1,23 +1,5 @@
<?php namespace Todaymade\Daux\Tree; <?php namespace Todaymade\Daux\Tree;
class ComputedRaw extends Entry class ComputedRaw extends ContentAbstract
{ {
/** @var string */
protected $content;
/**
* @return string
*/
public function getContent()
{
return $this->content;
}
/**
* @param string $content
*/
public function setContent($content)
{
$this->content = $content;
}
} }

View File

@ -2,7 +2,7 @@
use Webuni\FrontMatter\FrontMatter; use Webuni\FrontMatter\FrontMatter;
class Content extends Entry class Content extends ContentAbstract
{ {
/** @var string */ /** @var string */
protected $content; protected $content;

View File

@ -0,0 +1,24 @@
<?php namespace Todaymade\Daux\Tree;
abstract class ContentAbstract extends Entry
{
/** @var string */
protected $content;
/**
* @return string
*/
public function getContent()
{
return $this->content;
}
/**
* @param string $content
*/
public function setContent($content)
{
$this->content = $content;
}
}

View File

View File

@ -1,12 +1,12 @@
/** global localStorage */
_ = {}; var _ = {};
_.now = Date.now || function() { _.now = Date.now || function() {
return new Date().getTime(); return new Date().getTime();
}; };
_.debounce = function(func, wait, immediate) { _.debounce = function(func, wait, immediate) {
var timeout, args, context, timestamp, result; var timeout, args, context, timestamp;
var later = function() { var later = function() {
var last = _.now() - timestamp; var last = _.now() - timestamp;
@ -16,8 +16,10 @@ _.debounce = function(func, wait, immediate) {
} else { } else {
timeout = null; timeout = null;
if (!immediate) { if (!immediate) {
result = func.apply(context, args); func.apply(context, args);
if (!timeout) context = args = null; if (!timeout) {
context = args = null;
}
} }
} }
}; };
@ -27,13 +29,15 @@ _.debounce = function(func, wait, immediate) {
args = arguments; args = arguments;
timestamp = _.now(); timestamp = _.now();
var callNow = immediate && !timeout; var callNow = immediate && !timeout;
if (!timeout) timeout = setTimeout(later, wait); if (!timeout) {
timeout = setTimeout(later, wait);
}
if (callNow) { if (callNow) {
result = func.apply(context, args); func.apply(context, args);
context = args = null; context = args = null;
} }
return result; return true;
}; };
}; };
@ -61,15 +65,11 @@ $(function () {
toggleCodeBlockBtns.removeClass("Button--active"); toggleCodeBlockBtns.removeClass("Button--active");
console.log("Toggle", codeBlockState);
switch (codeBlockState) { switch (codeBlockState) {
default: case 2: // Show code blocks inline
case 0: // Hidden code blocks toggleCodeBlockBtnFloat.addClass("Button--active");
toggleCodeBlockBtnHide.addClass("Button--active"); codeBlockView.addClass('Columns__right--float');
toggleCodeBlockBtn.html("Show Code Blocks"); codeBlocks.removeClass('hidden');
codeBlockView.removeClass('Columns__right--float');
codeBlocks.addClass('hidden');
break; break;
case 1: // Show code blocks below case 1: // Show code blocks below
toggleCodeBlockBtnBelow.addClass("Button--active"); toggleCodeBlockBtnBelow.addClass("Button--active");
@ -77,10 +77,12 @@ $(function () {
codeBlockView.removeClass('Columns__right--float'); codeBlockView.removeClass('Columns__right--float');
codeBlocks.removeClass('hidden'); codeBlocks.removeClass('hidden');
break; break;
case 2: // Show code blocks inline case 0: // Hidden code blocks
toggleCodeBlockBtnFloat.addClass("Button--active"); default:
codeBlockView.addClass('Columns__right--float'); toggleCodeBlockBtnHide.addClass("Button--active");
codeBlocks.removeClass('hidden'); toggleCodeBlockBtn.html("Show Code Blocks");
codeBlockView.removeClass('Columns__right--float');
codeBlocks.addClass('hidden');
break; break;
} }
} }