EscolaLMS/topic-types

View on GitHub
Added phpstan #301
Witold Wiśniewski authored 90850409
complete00:00:31
Your first build completed successfully!

Congratulations

Your first build completed successfully!

See the Results

1
git clone
2
codeclimate validate-config
View output
codeclimate validate-config
No errors or warnings found in .codeclimate.json.
3
codeclimate prepare
View output
codeclimate prepare
4
builder pull-engines
View output
determining required images
docker pull codeclimate/codeclimate-phpcodesniffer:b163
b163: Pulling from codeclimate/codeclimate-phpcodesniffer
a0710691c81a: Pulling fs layer
a3ed95caeb02: Pulling fs layer
f3c17b6c6935: Pulling fs layer
c3166a36a8d9: Pulling fs layer
83a051f0858f: Pulling fs layer
f0e9f15ec462: Pulling fs layer
034c114563b8: Pulling fs layer
5edc25e33d4e: Pulling fs layer
83a051f0858f: Waiting
f0e9f15ec462: Waiting
034c114563b8: Waiting
5edc25e33d4e: Waiting
c3166a36a8d9: Waiting
a3ed95caeb02: Download complete
f3c17b6c6935: Download complete
a0710691c81a: Download complete
83a051f0858f: Verifying Checksum
83a051f0858f: Download complete
a0710691c81a: Pull complete
a3ed95caeb02: Pull complete
f0e9f15ec462: Verifying Checksum
f0e9f15ec462: Download complete
034c114563b8: Verifying Checksum
034c114563b8: Download complete
c3166a36a8d9: Verifying Checksum
c3166a36a8d9: Download complete
f3c17b6c6935: Pull complete
5edc25e33d4e: Verifying Checksum
5edc25e33d4e: Download complete
c3166a36a8d9: Pull complete
83a051f0858f: Pull complete
f0e9f15ec462: Pull complete
034c114563b8: Pull complete
5edc25e33d4e: Pull complete
Digest: sha256:cab8fcc753b6ae0e309b899665b22b1b62c26c56dab9b3c6a938fa72ca7c0640
Status: Downloaded newer image for registry.prod.codeclimate.net/codeclimate/codeclimate-phpcodesniffer:b163
docker pull codeclimate/codeclimate-phpmd:b291
b291: Pulling from codeclimate/codeclimate-phpmd
41dcc117e123: Pulling fs layer
e7cb8c1bd7da: Pulling fs layer
382dd9e936d2: Pulling fs layer
01d3fd4ccf07: Pulling fs layer
d54cbc0233c4: Pulling fs layer
a01b3d804127: Pulling fs layer
02aaff91dfc2: Pulling fs layer
25d9a4b72163: Pulling fs layer
378b764b6ee5: Pulling fs layer
d8ae1ee899c7: Pulling fs layer
f11257bedacf: Pulling fs layer
40adf26d4529: Pulling fs layer
01d3fd4ccf07: Waiting
d54cbc0233c4: Waiting
a01b3d804127: Waiting
02aaff91dfc2: Waiting
25d9a4b72163: Waiting
378b764b6ee5: Waiting
f11257bedacf: Waiting
40adf26d4529: Waiting
d8ae1ee899c7: Waiting
e7cb8c1bd7da: Verifying Checksum
e7cb8c1bd7da: Download complete
382dd9e936d2: Verifying Checksum
382dd9e936d2: Download complete
41dcc117e123: Verifying Checksum
41dcc117e123: Download complete
d54cbc0233c4: Verifying Checksum
d54cbc0233c4: Download complete
01d3fd4ccf07: Verifying Checksum
01d3fd4ccf07: Download complete
41dcc117e123: Pull complete
02aaff91dfc2: Download complete
25d9a4b72163: Verifying Checksum
25d9a4b72163: Download complete
a01b3d804127: Verifying Checksum
a01b3d804127: Download complete
e7cb8c1bd7da: Pull complete
382dd9e936d2: Pull complete
f11257bedacf: Verifying Checksum
f11257bedacf: Download complete
d8ae1ee899c7: Verifying Checksum
d8ae1ee899c7: Download complete
378b764b6ee5: Verifying Checksum
378b764b6ee5: Download complete
40adf26d4529: Verifying Checksum
40adf26d4529: Download complete
01d3fd4ccf07: Pull complete
d54cbc0233c4: Pull complete
a01b3d804127: Pull complete
02aaff91dfc2: Pull complete
25d9a4b72163: Pull complete
378b764b6ee5: Pull complete
d8ae1ee899c7: Pull complete
f11257bedacf: Pull complete
40adf26d4529: Pull complete
Digest: sha256:100ad83154de1d7143edb4360753a5a3c2c35f8a0fd8f00352718003e2b63bfa
Status: Downloaded newer image for registry.prod.codeclimate.net/codeclimate/codeclimate-phpmd:b291
docker pull codeclimate/codeclimate-sonar-php:b23
b23: Pulling from codeclimate/codeclimate-sonar-php
97518928ae5f: Pulling fs layer
043df9f67e9a: Pulling fs layer
a42e650909d2: Pulling fs layer
0dff3d7a1a0e: Pulling fs layer
e109c25d106c: Pulling fs layer
b2fb00c172a9: Pulling fs layer
1519b1438731: Pulling fs layer
cfbd8af1af7a: Pulling fs layer
ea3b98fb78f4: Pulling fs layer
1c654bf89a09: Pulling fs layer
0dff3d7a1a0e: Waiting
e109c25d106c: Waiting
b2fb00c172a9: Waiting
1519b1438731: Waiting
cfbd8af1af7a: Waiting
ea3b98fb78f4: Waiting
1c654bf89a09: Waiting
a42e650909d2: Verifying Checksum
a42e650909d2: Download complete
97518928ae5f: Verifying Checksum
97518928ae5f: Download complete
e109c25d106c: Verifying Checksum
e109c25d106c: Download complete
97518928ae5f: Pull complete
b2fb00c172a9: Verifying Checksum
b2fb00c172a9: Download complete
0dff3d7a1a0e: Verifying Checksum
0dff3d7a1a0e: Download complete
cfbd8af1af7a: Verifying Checksum
cfbd8af1af7a: Download complete
043df9f67e9a: Verifying Checksum
043df9f67e9a: Download complete
1519b1438731: Verifying Checksum
1519b1438731: Download complete
1c654bf89a09: Verifying Checksum
1c654bf89a09: Download complete
043df9f67e9a: Pull complete
a42e650909d2: Pull complete
ea3b98fb78f4: Verifying Checksum
ea3b98fb78f4: Download complete
0dff3d7a1a0e: Pull complete
e109c25d106c: Pull complete
b2fb00c172a9: Pull complete
1519b1438731: Pull complete
cfbd8af1af7a: Pull complete
ea3b98fb78f4: Pull complete
1c654bf89a09: Pull complete
Digest: sha256:600639355d67f629857951762cd4d8d2bc9eb16a0496c67a3d6049830edcc87b
Status: Downloaded newer image for registry.prod.codeclimate.net/codeclimate/codeclimate-sonar-php:b23
5
structure
View output
12
Parser process id: 12
codeclimate-parser socket not present
waiting 1s...
W, [2024-11-21T09:26:46.230048 #1]  WARN -- : Skipping database/factories/TopicResourceFactory.php due to CC::Parser::Client::HTTPError
W, [2024-11-21T09:26:46.230078 #1]  WARN -- : Response status: 422
6
duplication
View output
12
Parser process id: 12
codeclimate-parser socket not present
waiting 1s...
W, [2024-11-21T09:26:49.866505 #1]  WARN -- : Skipping ./database/factories/TopicResourceFactory.php due to CC::Parser::Client::HTTPError
W, [2024-11-21T09:26:49.866543 #1]  WARN -- : Response status: 422
7
phpcodesniffer
phpcodesniffer engine documentation
8
phpmd
phpmd engine documentation
9
sonar-php
sonar-php engine documentation
View output
INFO: Java 1.8.0_322 Amazon.com Inc. (64-bit)
INFO: Linux 4.4.0-1128-aws amd64
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/src/app/build/libs/sonarlint-core-2.17.0.899.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/src/app/build/libs/sonarlint-cli-2.1.0.566.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
INFO: Index files
INFO: Invalid character encountered in file '/code/database/seeders/avatar.jpg' at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: Invalid character encountered in file '/code/database/mocks/poster.jpg' at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: Invalid character encountered in file '/code/database/mocks/scorm.zip' at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: Invalid character encountered in file '/code/database/mocks/1.jpg' at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: Invalid character encountered in file '/code/database/mocks/1.pdf' at line 6 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: Invalid character encountered in file '/code/database/mocks/1.mp4' at line 2 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: Invalid character encountered in file '/code/database/mocks/cmi5.zip' at line 2 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: Invalid character encountered in file '/code/database/mocks/hp5.h5p' at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: Invalid character encountered in file '/code/database/mocks/1.mp3' at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: Invalid character encountered in file '/code/docs/topic_types.png' at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: 108 files indexed
INFO: 82 source files to be analyzed
ERROR: Unable to parse file: /code/src/Helpers/Markdown.php
ERROR: Parse error at line 56 column 30:

46:             function ($match) use ($destinationPrefix, &$results) {
47:                 $filepath = $match[3] ?? null;
48:                 $basename = basename($filepath);
49:                 $destination = sprintf($destinationPrefix . '%s', $basename);
50: 
51:                 if(str_contains($filepath, 'http') && !str_starts_with($filepath, url('/'))) {
52:                   return str_replace($match[3], $match[3], $match[0]);
53:                 }
54: 
55:                 // three scenarios
56:                 match (true) {
                                 ^
57:                     str_contains($filepath, 'api/images/img') => $results[] = $this->convertFilePathByApiPattern($destinationPrefix, $filepath, $destination),
58:                     str_contains($filepath, 'storage') => $results[] = $this->convertFilePathByStorage($filepath, $destination),
59:                     str_contains($filepath, 'http') => $results[] = $this->convertFilePathByHttp($destinationPrefix, $filepath, $destination),
60:                     default => $results[] = null,
61:                 };
62: 
63:                 return str_replace($match[3], $destination, $match[0]);
64:             },
65:             $input
66:         );

ERROR: Unable to parse file: /code/src/EscolaLmsTopicTypesServiceProvider.php
ERROR: Parse error at line 143 column 20:

133:                 'client' => ClientCmi5AuResource::class,
134:                 'admin' => AdminCmi5AuResource::class,
135:                 'export' => ExportCmi5AuResource::class,
136:             ]);
137:         }
138:     }
139: 
140:     public function register()
141:     {
142:         H5PContentRepository::extendQueryJoin(
143:             fn () => [['topic_h5ps.value', 'hh5p_contents.id']],
                        ^
144:             'topic_h5ps'
145:         );
146:         H5PContentRepository::extendQuerySelect(
147:             fn () => DB::raw("COUNT(topic_h5ps.value) as count_h5p"),
148:             'topic_h5ps'
149:         );
150:         H5PContentRepository::extendQueryGroupBy(
151:             fn () => [
152:                 'hh5p_contents.id',
153:                 'hh5p_contents.uuid',

ERROR: Unable to parse file: /code/src/Models/TopicContent/AbstractTopicFileContent.php
ERROR: Parse error at line 26 column 65:

16: {
17:     protected $appends = ['url'];
18: 
19:     public function getFileKeyNames(): array
20:     {
21:         return Collection::make($this->rules())
22:             ->filter(function ($fieldRules) {
23:                 if (is_array($fieldRules)) {
24:                     return in_array('file', $fieldRules) ||
25:                         in_array('image', $fieldRules) ||
26:                         collect($fieldRules)->filter(fn($rule) => strpos($rule, 'mimes') !== false)->count();
                                                                    ^
27:                 }
28: 
29:                 return  strpos('file', $fieldRules) !== false ||
30:                         strpos('image', $fieldRules) !== false;
31:             })
32:             ->keys()
33:             ->toArray();
34:     }
35: 
36:     public function generateStoragePath(?string $basePath = null): string

ERROR: Unable to parse file: /code/src/Events/TopicTypeChanged.php
ERROR: Parse error at line 15 column 21:

 5: use EscolaLms\TopicTypes\Models\TopicContent\AbstractTopicContent;
 6: use Illuminate\Contracts\Auth\Authenticatable;
 7: use Illuminate\Foundation\Events\Dispatchable;
 8: use Illuminate\Queue\SerializesModels;
 9: 
10: class TopicTypeChanged
11: {
12:     use Dispatchable;
13:     use SerializesModels;
14: 
15:     private AbstractTopicContent $topicContent;
                        ^
16:     private ?Authenticatable $user;
17: 
18:     public function __construct(?Authenticatable $user, AbstractTopicContent $topicContent)
19:     {
20:         $this->topicContent = $topicContent;
21:         $this->user = $user;
22:     }
23: 
24:     public function getTopicContent(): AbstractTopicContent
25:     {

ERROR: Unable to parse file: /code/database/seeders/CoursesWithTopicSeeder.php
ERROR: Parse error at line 82 column 50:

72:         foreach ($tutors as $tutor) {
73:             $tutor->update([
74:                 'path_avatar' => 'tutor_avatar.jpg',
75:             ]);
76:         }
77: 
78:         $courses = Course::factory()
79:             ->count(random_int(5, 10))
80:             ->has(Lesson::factory()
81:                 ->count(random_int(2, 3))
82:                 ->state(new Sequence(fn(Sequence $sequence) => ['title' => 'Subject ' . $this->faker->word]))
                                                     ^
83:                 ->has(Lesson::factory()
84:                     ->count(random_int(2, 3))
85:                     ->state(new Sequence(fn(Sequence $sequence) => ['title' => 'Module ' . $this->faker->word]))
86:                     ->has(Lesson::factory()
87:                         ->count(random_int(2, 3))
88:                         ->state(new Sequence(fn(Sequence $sequence) => ['title' => 'Topic ' . $this->faker->word]))
89:                         ->has(Lesson::factory()
90:                             ->count(random_int(2, 3))
91:                             ->state(new Sequence(fn(Sequence $sequence) => ['title' => 'Lesson ' . $this->faker->word]))
92:                             ->afterCreating(function (Lesson $lesson) use ($hasH5P) {

ERROR: Unable to parse file: /code/database/factories/TopicResourceFactory.php
ERROR: Parse error at line 43 column 95:

33: 
34:     public function forTopic(Topic $topic)
35:     {
36:         return $this->state(function () use ($topic) {
37:             $topicId = $topic->getKey();
38:             $path = "topic/{$topicId}/resources/";
39:             $filename = "{$this->faker->word}.pdf";
40:             $dest = Storage::disk('public')->path($path . $filename);
41:             $destDir = dirname($dest);
42:             
43:             Storage::putFileAs($path, new File(realpath(__DIR__.'/../mocks/1.pdf'), $filename);
                                                                                                  ^
44: 
45:             return [
46:                 'topic_id' => $topic,
47:                 'path' => $path,
48:                 'name' => $filename,
49:             ];
50:         });
51:     }
52: }
53: 

INFO: 82/82 source files have been analyzed
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 1.175s
INFO: Final Memory: 9M/163M
INFO: ------------------------------------------------------------------------