Skip to content

Commit 1e622e1

Browse files
committed
Merge branch 'main' into redsun82/kotlin
2 parents a23327c + 332d118 commit 1e622e1

File tree

308 files changed

+227
-111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

308 files changed

+227
-111
lines changed

.github/workflows/buildifier.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check bazel formatting
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "**.bazel"
7+
- "**.bzl"
8+
branches:
9+
- main
10+
- "rc/*"
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
check:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Check bazel formatting
22+
uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507
23+
with:
24+
extra_args: >
25+
buildifier --all-files 2>&1 ||
26+
(
27+
echo -e "In order to format all bazel files, please run:\n bazel run //:buildifier"; exit 1
28+
)

.pre-commit-config.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ repos:
2020
- id: autopep8
2121
files: ^misc/codegen/.*\.py
2222

23-
- repo: https://github.com/warchant/pre-commit-buildifier
24-
rev: 0.0.2
23+
- repo: local
2524
hooks:
2625
- id: buildifier
26+
name: Format bazel files
27+
files: \.(bazel|bzl)
28+
language: system
29+
entry: bazel run //:buildifier
30+
pass_filenames: false
2731

28-
- repo: local
29-
hooks:
3032
- id: codeql-format
3133
name: Fix QL file formatting
3234
files: \.qll?$

BUILD.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
2+
3+
buildifier(
4+
name = "buildifier",
5+
exclude_patterns = [
6+
"./.git/*",
7+
],
8+
lint_mode = "fix",
9+
)

MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json")
2323
bazel_dep(name = "fmt", version = "10.0.0")
2424
bazel_dep(name = "rules_kotlin", version = "1.9.4-codeql.1")
2525

26+
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
27+
2628
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
2729
pip.parse(
2830
hub_name = "codegen_deps",

config/identical-files.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@
362362
"java/ql/lib/semmle/code/java/security/internal/EncryptionKeySizes.qll"
363363
],
364364
"Python model summaries test extension": [
365-
"python/ql/test/experimental/dataflow/model-summaries/InlineTaintTest.ext.yml",
366-
"python/ql/test/experimental/dataflow/model-summaries/NormalDataflowTest.ext.yml"
365+
"python/ql/test/library-tests/dataflow/model-summaries/InlineTaintTest.ext.yml",
366+
"python/ql/test/library-tests/dataflow/model-summaries/NormalDataflowTest.ext.yml"
367367
]
368-
}
368+
}

cpp/ql/test/library-tests/ir/ir/ir.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2432,7 +2432,7 @@ void initialization_with_temp_destructor() {
24322432
}
24332433

24342434
void param_with_destructor_by_value(ClassWithDestructor c) {
2435-
// The call to ~ClassWithDestructor::ClassWithDestructor() seems to be missing here.
2435+
// The call to ~ClassWithDestructor::ClassWithDestructor() happens on the side of the caller
24362436
}
24372437

24382438
void param_with_destructor_by_pointer(ClassWithDestructor* c) {

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private static BuildScript DownloadDotNet(IBuildActions actions, ILogger logger,
143143
// See https://docs.microsoft.com/en-us/dotnet/core/tools/global-json
144144
var versions = new List<string>();
145145

146-
foreach (var path in files.Where(p => p.EndsWith("global.json", StringComparison.Ordinal)))
146+
foreach (var path in files.Where(p => string.Equals(FileUtils.SafeGetFileName(p, logger), "global.json", StringComparison.OrdinalIgnoreCase)))
147147
{
148148
try
149149
{

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FileContent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private void DoInitialize()
184184
{
185185
try
186186
{
187-
var isPackagesConfig = file.EndsWith("packages.config", StringComparison.OrdinalIgnoreCase);
187+
var isPackagesConfig = string.Equals(FileUtils.SafeGetFileName(file, logger), "packages.config", StringComparison.OrdinalIgnoreCase);
188188

189189
foreach (ReadOnlySpan<char> line in unsafeFileReader.ReadLines(file))
190190
{

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/SourceGenerators/DotnetSourceGeneratorBase.cs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected override IEnumerable<string> Run()
5555

5656
// group additional files by closes project file:
5757
var projects = fileProvider.Projects
58-
.Select(p => (File: p, Directory: SafeGetDirectoryName(p)))
58+
.Select(p => (File: p, Directory: FileUtils.SafeGetDirectoryName(p, logger)))
5959
.Where(p => p.Directory.Length > 0);
6060

6161
var groupedFiles = new Dictionary<string, List<string>>();
@@ -93,30 +93,6 @@ protected override IEnumerable<string> Run()
9393
}
9494
}
9595

96-
private string SafeGetDirectoryName(string fileName)
97-
{
98-
try
99-
{
100-
var dir = Path.GetDirectoryName(fileName);
101-
if (dir is null)
102-
{
103-
return "";
104-
}
105-
106-
if (!dir.EndsWith(Path.DirectorySeparatorChar))
107-
{
108-
dir += Path.DirectorySeparatorChar;
109-
}
110-
111-
return dir;
112-
}
113-
catch (Exception ex)
114-
{
115-
logger.LogDebug($"Failed to get directory name for {fileName}: {ex.Message}");
116-
return "";
117-
}
118-
}
119-
12096
protected abstract ICollection<string> AdditionalFiles { get; }
12197

12298
protected abstract string FileType { get; }

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/SourceGenerators/ResxGenerator.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ public ResxGenerator(
1919
TemporaryDirectory tempWorkingDirectory,
2020
IEnumerable<string> references) : base(fileProvider, fileContent, dotnet, compilationInfoContainer, logger, tempWorkingDirectory, references)
2121
{
22+
if (fileProvider.Resources.Count == 0)
23+
{
24+
logger.LogDebug("No resources found, skipping resource extraction.");
25+
sourceGeneratorFolder = null;
26+
return;
27+
}
28+
2229
try
2330
{
2431
// The package is downloaded to `missingpackages`, which is okay, we're already after the DLL collection phase.

0 commit comments

Comments
 (0)