Fix some more code style issues

This commit is contained in:
Timothy Warren 2015-11-05 11:26:03 -05:00
parent cdb4406e14
commit d3541da789
6 changed files with 41 additions and 13 deletions

4
.scrutinizer.yml Normal file
View File

@ -0,0 +1,4 @@
# .scrutinizer.yml
tools:
external_code_coverage:
timeout: 600 # Timeout in seconds.

View File

@ -8,6 +8,7 @@
<property name="phploc" value="phploc"/>
<property name="phpmd" value="phpmd"/>
<property name="phpunit" value="phpunit"/>
<property name="sonar" value="sonar-runner"/>
<!-- Use this when the tools are located as PHARs in ${basedir}/build/tools
<property name="pdepend" value="${basedir}/build/tools/pdepend.phar"/>
@ -28,7 +29,7 @@
<property name="phpunit" value="${basedir}/vendor/bin/phpunit"/> -->
<target name="full-build"
depends="prepare,static-analysis,phpunit,phpdox,-check-failure"
depends="prepare,static-analysis,phpunit,phpdox,sonar,-check-failure"
description="Performs static analysis, runs the tests, and generates project documentation"/>
<target name="full-build-parallel"
@ -231,6 +232,12 @@
<property name="phpdox.done" value="true"/>
</target>
<target name="sonar"
depends="phpunit">
<exec executable="${sonar}" taskname="sonar"/>
<property name="sonar.done" value="true"/>
</target>
<target name="-check-failure">
<fail message="PHPUnit did not finish successfully">
<condition>

View File

@ -1,4 +1,6 @@
sonar.projectKey=animeclient
sonar.projectName=Anime Client
sonar.projectVersion=1.0
sonar.sources=src
sonar.sources=src
sonar.php.coverage.overallReportPath=build/logs/clover.xml
sonar.php.tests.reportPath=build/logs/junit.xml

View File

@ -94,8 +94,7 @@ class API extends BaseModel {
}
array_unshift($args, strtoupper($method));
$response = call_user_func_array([$this->client, 'request'], $args);
return $response;
return call_user_func_array([$this->client, 'request'], $args);
}
/**

View File

@ -75,7 +75,10 @@ class AnimeCollection extends DB {
->join('genres g', 'g.id=gl.genre_id', 'left');
if ( ! empty($filter)) $this->db->where_in('hummingbird_id', $filter);
if ( ! empty($filter))
{
$this->db->where_in('hummingbird_id', $filter);
}
$query = $this->db->order_by('hummingbird_id')
->order_by('genre')
@ -89,8 +92,10 @@ class AnimeCollection extends DB {
$genre = $row['genre'];
// Empty genre names aren't useful
if (empty($genre)) continue;
if (empty($genre))
{
continue;
}
if (array_key_exists($id, $output))
{
@ -174,7 +179,10 @@ class AnimeCollection extends DB {
*/
private function _get_collection()
{
if ( ! $this->valid_database) return [];
if ( ! $this->valid_database)
{
return [];
}
$query = $this->db->select('hummingbird_id, slug, title, alternate_title, show_type,
age_rating, episode_count, episode_length, cover_image, notes, media.type as media')
@ -225,7 +233,10 @@ class AnimeCollection extends DB {
public function update($data)
{
// If there's no id to update, don't update
if ( ! array_key_exists('hummingbird_id', $data)) return;
if ( ! array_key_exists('hummingbird_id', $data))
{
return;
}
$id = $data['hummingbird_id'];
unset($data['hummingbird_id']);
@ -257,8 +268,10 @@ class AnimeCollection extends DB {
*/
private function json_import()
{
if ( ! file_exists('import.json')) return;
if ( ! $this->valid_database) return;
if ( ! file_exists('import.json') || ! $this->valid_database)
{
return;
}
$anime = json_decode(file_get_contents("import.json"));

View File

@ -66,7 +66,7 @@ class Manga extends API {
{
$data = $this->_get_list_from_api();
foreach ($data as $key => &$val)
foreach ($data as &$val)
{
$this->sort_by_name($val);
}
@ -121,7 +121,10 @@ class Manga extends API {
{
// Bail out early if there isn't any manga data
$api_data = json_decode($response->getBody(), TRUE);
if ( ! array_key_exists('manga', $api_data)) return [];
if ( ! array_key_exists('manga', $api_data))
{
return [];
}
$cache_file = _dir($this->config->get('data_cache_path'), 'manga.json');
$transformed_cache_file = _dir($this->config->get('data_cache_path'), 'manga-transformed.json');