Skip to content

Commit 837c8de

Browse files
Resolve Yaml Parser exception (#877)
Fixes #876
1 parent d64600b commit 837c8de

File tree

8 files changed

+59
-52
lines changed

8 files changed

+59
-52
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.sap.oss.phosphor</groupId>
88
<artifactId>fosstars-rating-core</artifactId>
9-
<version>1.12.0-SNAPSHOT</version>
9+
<version>1.11.1-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Fosstars Rating Core</name>

src/main/java/com/sap/oss/phosphor/fosstars/advice/oss/github/OssSecurityGithubAdvisor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ public OssSecurityGithubAdvisor() {
4242
new SnykAdvisor(AdviceForGitHubContextFactory.INSTANCE),
4343
new GoSecAdvisor(AdviceForGitHubContextFactory.INSTANCE));
4444
}
45-
}
45+
}

src/main/java/com/sap/oss/phosphor/fosstars/data/AbstractStaticScanToolsDataProvider.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ public static class Visitor extends AbstractGitHubVisitor {
432432
@Override
433433
public void visitPreCommitHook(LocalRepository repository,
434434
Map<String, Predicate<String>> matchers, Set<Location> locations) throws IOException {
435-
Optional<InputStream> content = repository.fileStream(PRE_COMMIT_HOOK_CONFIG);
435+
Optional<InputStream> content = repository.read(PRE_COMMIT_HOOK_CONFIG);
436436
if (!content.isPresent()) {
437437
return;
438438
}

src/main/java/com/sap/oss/phosphor/fosstars/data/github/LocalRepository.java

-31
Original file line numberDiff line numberDiff line change
@@ -213,37 +213,6 @@ public Optional<String> file(Path file) throws IOException {
213213
return Optional.of(IOUtils.toString(is, UTF_8));
214214
}
215215
}
216-
217-
/**
218-
* Returns a content of a file if it exists.
219-
*
220-
* @param file The file name.
221-
* @return A inputstream of the file.
222-
* @throws IOException If something went wrong.
223-
*/
224-
public Optional<InputStream> fileStream(String file) throws IOException {
225-
Objects.requireNonNull(file, "On no! File name is null!");
226-
return fileStream(Paths.get(file));
227-
}
228-
229-
/**
230-
* Returns a content of a file if it exists.
231-
*
232-
* @param file The file name.
233-
* @return A inputstream of the file.
234-
* @throws IOException If something went wrong.
235-
*/
236-
public Optional<InputStream> fileStream(Path file) throws IOException {
237-
Objects.requireNonNull(file, "On no! File name is null!");
238-
Path path = info.path().resolve(file);
239-
if (!Files.isRegularFile(path)) {
240-
return Optional.empty();
241-
}
242-
243-
try (InputStream is = Files.newInputStream(path)) {
244-
return Optional.ofNullable(is);
245-
}
246-
}
247216

248217
/**
249218
* Checks if the repository has a specified directory.

src/main/java/com/sap/oss/phosphor/fosstars/data/github/UsesSnyk.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ private boolean hasSnykPolicy(LocalRepository repository) throws IOException {
103103
List<Path> snykPolicyFilePaths = repository.files(SNYK_FILE_PREDICATE);
104104
return !snykPolicyFilePaths.isEmpty();
105105
}
106-
}
106+
}

src/test/java/com/sap/oss/phosphor/fosstars/data/github/MyPyDataProviderTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private void testPylintFileStreamCheck(String filename, InputStream content,
126126
Files.createDirectories(file.getParent());
127127
when(localRepository.hasDirectory(any(Path.class))).thenReturn(true);
128128
IOUtils.copy(content, Files.newOutputStream(file));
129-
when(localRepository.fileStream(any(String.class)))
129+
when(localRepository.read(any(String.class)))
130130
.thenReturn(Optional.of(Files.newInputStream(file)));
131131

132132
MyPyDataProvider provider = new MyPyDataProvider(fetcher);

src/test/java/com/sap/oss/phosphor/fosstars/data/github/PylintDataProviderTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ private void testPylintFileStreamCheck(String filename, InputStream content,
199199
Files.createDirectories(file.getParent());
200200
when(localRepository.hasDirectory(any(Path.class))).thenReturn(true);
201201
IOUtils.copy(content, Files.newOutputStream(file));
202-
when(localRepository.fileStream(any(String.class)))
202+
when(localRepository.read(any(String.class)))
203203
.thenReturn(Optional.of(Files.newInputStream(file)));
204204

205205
PylintDataProvider provider = new PylintDataProvider(fetcher);
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,59 @@
1-
fail_fast: true
2-
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
317
repos:
4-
- repo: https://github.com/ambv/black
18+
- repo: https://github.com/PyCQA/isort
19+
rev: 5.9.3
20+
hooks:
21+
- id: isort
22+
- repo: https://github.com/pre-commit/mirrors-mypy
23+
rev: v0.941
24+
hooks:
25+
- id: mypy
26+
additional_dependencies: [types-all]
27+
- repo: https://github.com/peterdemin/pip-compile-multi
28+
rev: v2.4.1
29+
hooks:
30+
- id: pip-compile-multi-verify
31+
- repo: https://github.com/pre-commit/pre-commit-hooks
32+
rev: v3.2.0
33+
hooks:
34+
- id: check-docstring-first
35+
- id: check-added-large-files
36+
exclude: \.(geojson)$
37+
- id: check-yaml
38+
exclude: ^helm/superset/templates/
39+
- id: debug-statements
40+
- id: end-of-file-fixer
41+
- id: trailing-whitespace
42+
args: ["--markdown-linebreak-ext=md"]
43+
- repo: https://github.com/psf/black
544
rev: 22.3.0
645
hooks:
746
- id: black
8-
args: [--diff, --check]
9-
10-
- repo: https://github.com/pre-commit/mirrors-pylint
11-
rev: v3.0.0a3
47+
language_version: python3
48+
- repo: https://github.com/pre-commit/mirrors-prettier
49+
rev: v2.4.1 # Use the sha or tag you want to point at
1250
hooks:
13-
- id: pylint
14-
args: [--disable=all, --enable=unused-import]
15-
16-
- repo: https://github.com/pre-commit/mirrors-mypy
17-
rev: v0.902
51+
- id: prettier
52+
args: ['--ignore-path=./superset-frontend/.prettierignore']
53+
files: 'superset-frontend'
54+
# blacklist unsafe functions like make_url (see #19526)
55+
- repo: https://github.com/skorokithakis/blacklist-pre-commit-hook
56+
rev: e2f070289d8eddcaec0b580d3bde29437e7c8221
1857
hooks:
19-
- id: mypy
20-
exclude: ^tests/
21-
args: [--strict]
58+
- id: blacklist
59+
args: ["--blacklisted-names=make_url", "--ignore=tests/"]

0 commit comments

Comments
 (0)