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,9 +77,11 @@ function createLinter() {
var style_tasks = [];
for (var style in resources) {
if (resources.hasOwnProperty(style)) {
gulp.task('style_' + style, createTask(resources[style].source, resources[style].dest));
style_tasks.push('style_' + style);
}
}
gulp.task('lint-css', createLinter);
style_tasks.push('lint-css');

View File

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

View File

@ -2,6 +2,7 @@
use GuzzleHttp\Client;
use GuzzleHttp\Exception\BadResponseException;
use GuzzleHttp\Exception\RequestException;
class Api
{
@ -42,7 +43,7 @@ class Api
* this will give little bit more sense to it and return it
*
* @param BadResponseException $e
* @return BadResponseException
* @return RequestException
*/
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)
{
if (!($inline instanceof Image)) {
throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
}
// External Images need special handling
if (strpos($inline->getUrl(), 'http') === 0) {
return new HtmlElement(

View File

@ -1,5 +1,5 @@
<?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());
$children = $entry->getChildren();
if ($children != null) {
foreach ($this->cloneChildren($entry->getContent()) as $node) {
$a->appendChild($node);
}
}
$p = new Paragraph();
$p->appendChild($a);

View File

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

View File

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