Skip to content

Commit d0126bd

Browse files
authored
Make InvalidRef a critical exception to avoid suppression (#122)
1 parent ec90855 commit d0126bd

File tree

11 files changed

+227
-77
lines changed

11 files changed

+227
-77
lines changed

.github/workflows/cloc.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: cloc
2+
on:
3+
pull_request:
4+
jobs:
5+
cloc:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout code
9+
uses: actions/checkout@v2
10+
with:
11+
path: pr
12+
- name: Checkout base code
13+
uses: actions/checkout@v2
14+
with:
15+
ref: ${{ github.event.pull_request.base.sha }}
16+
path: base
17+
- name: Count Lines Of Code
18+
id: loc
19+
run: |
20+
curl -OL https://github.com/vearutop/sccdiff/releases/download/v1.0.1/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz
21+
OUTPUT=$(cd pr && ../sccdiff -basedir ../base)
22+
OUTPUT="${OUTPUT//'%'/'%25'}"
23+
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
24+
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
25+
echo "::set-output name=diff::$OUTPUT"
26+
27+
- name: Comment Code Lines
28+
uses: marocchino/sticky-pull-request-comment@v2
29+
with:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
header: LOC
32+
message: |
33+
### Lines Of Code
34+
35+
${{ steps.loc.outputs.diff }}

.github/workflows/lint.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: lint
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- main
7+
pull_request:
8+
jobs:
9+
run:
10+
runs-on: ${{ matrix.operating-system }}
11+
strategy:
12+
matrix:
13+
operating-system: [ 'ubuntu-latest' ]
14+
php-versions: [ '7.4' ]
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
19+
- name: Cache vendor
20+
uses: actions/cache@v2
21+
with:
22+
path: |
23+
vendor
24+
key: vendor-${{ hashFiles('composer.lock') }}
25+
26+
- name: Setup PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: ${{ matrix.php-versions }}
30+
ini-values: post_max_size=256M, max_execution_time=180
31+
tools: composer
32+
33+
- name: Populate vendor
34+
run: '[ -e vendor ] || composer install'
35+
36+
- name: Lint
37+
run: make lint

.github/workflows/test-unit-cov.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: test-unit-cov
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- main
7+
pull_request:
8+
jobs:
9+
run:
10+
runs-on: ${{ matrix.operating-system }}
11+
strategy:
12+
matrix:
13+
operating-system: [ 'ubuntu-latest' ]
14+
php-versions: [ '7.4' ]
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
19+
- name: Cache vendor
20+
uses: actions/cache@v2
21+
with:
22+
path: |
23+
vendor
24+
key: vendor-${{ hashFiles('composer.lock') }}
25+
26+
- name: Setup PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: ${{ matrix.php-versions }}
30+
ini-values: post_max_size=256M, max_execution_time=180
31+
coverage: xdebug
32+
tools: composer
33+
34+
- name: Populate vendor
35+
run: '[ -e vendor ] || composer install'
36+
37+
- name: Run Tests With Coverage
38+
run: make deps test-coverage && bash <(curl -s https://codecov.io/bash)

.github/workflows/test-unit.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: test-unit
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- main
7+
pull_request:
8+
jobs:
9+
run:
10+
runs-on: ${{ matrix.operating-system }}
11+
strategy:
12+
matrix:
13+
operating-system: [ 'ubuntu-latest' ]
14+
php-versions: [ '5.6', '7.0', '7.1', '7.2', '7.3', '8.0' ]
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
19+
- name: Cache vendor
20+
uses: actions/cache@v2
21+
with:
22+
path: |
23+
vendor
24+
key: vendor-${{ hashFiles('composer.lock') }}
25+
26+
- name: Setup PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: ${{ matrix.php-versions }}
30+
ini-values: post_max_size=256M, max_execution_time=180
31+
tools: composer
32+
33+
- name: Populate vendor
34+
run: '[ -e vendor ] || composer install'
35+
36+
- name: Run Tests
37+
run: make deps test

.scrutinizer.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.12.35] - 2021-06-18
8+
9+
### Fixed
10+
- Suppressed failure during reference resolution in complex schemas.
11+
712
## [0.12.34] - 2021-06-17
813

914
### Fixed
@@ -83,6 +88,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8388
### Changed
8489
- Export `null` value instead of skipping it for properties having `null` type.
8590

91+
[0.12.35]: https://github.com/swaggest/php-json-schema/compare/v0.12.34...v0.12.35
8692
[0.12.34]: https://github.com/swaggest/php-json-schema/compare/v0.12.33...v0.12.34
8793
[0.12.33]: https://github.com/swaggest/php-json-schema/compare/v0.12.32...v0.12.33
8894
[0.12.32]: https://github.com/swaggest/php-json-schema/compare/v0.12.31...v0.12.32

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ deps:
55
@git submodule init && git submodule update
66

77
lint:
8-
@test -f ${HOME}/.cache/composer/phpstan-${PHPSTAN_VERSION}.phar || (mkdir -p ${HOME}/.cache/composer/ && wget https://github.com/phpstan/phpstan/releases/download/${PHPSTAN_VERSION}/phpstan.phar -O ${HOME}/.cache/composer/phpstan-${PHPSTAN_VERSION}.phar)
8+
@test -f ${HOME}/.cache/composer/phpstan-${PHPSTAN_VERSION}.phar || (mkdir -p ${HOME}/.cache/composer/ && wget -q https://github.com/phpstan/phpstan/releases/download/${PHPSTAN_VERSION}/phpstan.phar -O ${HOME}/.cache/composer/phpstan-${PHPSTAN_VERSION}.phar)
99
@php $$HOME/.cache/composer/phpstan-${PHPSTAN_VERSION}.phar analyze -l 7 -c phpstan.neon ./src
1010

1111
docker-lint:

src/InvalidRef.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Swaggest\JsonSchema;
44

5-
class InvalidRef extends InvalidValue
5+
class InvalidRef extends Exception
66
{
77

88
}

src/Schema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ private function processObject($data, Context $options, $path, $result = null)
736736
$ref->setImported($refResult);
737737
return $refResult;
738738
} catch (InvalidValue $exception) {
739-
if ($this->objectItemClass === 'Swaggest\JsonSchema\Schema' || $exception instanceof InvalidRef) {
739+
if ($this->objectItemClass === 'Swaggest\JsonSchema\Schema') {
740740
throw $exception;
741741
}
742742

0 commit comments

Comments
 (0)