-
-
Couldn't load subscription status.
- Fork 78
Release candidate v3.69.0 #727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ol on what is logged), ref #725
| } | ||
|
|
||
| return Wt::asNumber(value(DemoField)) ? UserType::DEMO : UserType::REGULAR; | ||
| return Wt::asNumber(value(DemoField)) ? db::UserType::DEMO : db::UserType::REGULAR; |
Check warning
Code scanning / CodeQL
Lossy function result cast Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 months ago
To fix the problem, we should make the conversion from double to bool explicit and clear. The best way to do this is to compare the result of Wt::asNumber(value(DemoField)) to zero, e.g., Wt::asNumber(value(DemoField)) != 0.0. This makes it clear that the code is checking for a non-zero value, and avoids the implicit cast. The change should be made on line 140 in the getUserType() method of the UserModel class in src/lms/ui/admin/UserView.cpp. No new imports or methods are needed.
-
Copy modified line R140
| @@ -139,3 +139,3 @@ | ||
|
|
||
| return Wt::asNumber(value(DemoField)) ? db::UserType::DEMO : db::UserType::REGULAR; | ||
| return (Wt::asNumber(value(DemoField)) != 0.0) ? db::UserType::DEMO : db::UserType::REGULAR; | ||
| } |
| auto transaction{ LmsApp->getDbSession().createReadTransaction() }; | ||
|
|
||
| if (Wt::asNumber(value(DemoField)) && User::findDemoUser(LmsApp->getDbSession())) | ||
| if (Wt::asNumber(value(DemoField)) && db::User::findDemoUser(LmsApp->getDbSession())) |
Check warning
Code scanning / CodeQL
Lossy function result cast Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 months ago
To fix the problem, we should avoid relying on the implicit conversion of a double to bool. Instead, we should explicitly compare the result of Wt::asNumber(value(DemoField)) to the value we expect to represent "true" (most likely 1.0). This makes the code's intent clear and avoids any confusion or bugs due to unexpected floating-point values. The best way to do this is to replace the condition in line 172 with an explicit comparison, such as Wt::asNumber(value(DemoField)) == 1.0. No new imports or methods are needed; only the condition in the if statement needs to be updated.
-
Copy modified line R172
| @@ -171,3 +171,3 @@ | ||
|
|
||
| if (Wt::asNumber(value(DemoField)) && db::User::findDemoUser(LmsApp->getDbSession())) | ||
| if (Wt::asNumber(value(DemoField)) == 1.0 && db::User::findDemoUser(LmsApp->getDbSession())) | ||
| error = Wt::WString::tr("Lms.Admin.User.demo-account-already-exists"); |
| using namespace db; | ||
|
|
||
| RangeResults<ArtistId> ArtistCollector::get(std::optional<db::Range> requestedRange) | ||
| db::RangeResults<db::ArtistId> ArtistCollector::get(std::optional<db::Range> requestedRange) |
Check warning
Code scanning / CodeQL
Poorly documented large function Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 months ago
To fix the problem, we should add meaningful comments to the ArtistCollector::get function to document its purpose, the overall flow, and the intent behind each major code block. This includes a function-level comment describing what the function does, its parameters, and return value, as well as inline comments for each case in the switch statement to clarify the logic and any important details. The changes should be made directly above and within the function in src/lms/ui/explore/ArtistCollector.cpp, specifically lines 35–142. No changes to functionality or logic are required—only the addition of comments.
-
Copy modified lines R35-R44 -
Copy modified line R47 -
Copy modified line R51 -
Copy modified line R56 -
Copy modified line R60 -
Copy modified line R66 -
Copy modified line R80 -
Copy modified line R94 -
Copy modified line R108 -
Copy modified line R117
| @@ -34,4 +34,15 @@ | ||
| { | ||
| /** | ||
| * @brief Retrieves a range of artist IDs based on the current collection mode and optional range. | ||
| * | ||
| * This function collects artist IDs according to the current mode set in the ArtistCollector. | ||
| * The mode determines the source and sorting of the artists (e.g., random, starred, recently played, etc.). | ||
| * It interacts with various services (feedback, scrobbling) and applies filters, keywords, and link types as needed. | ||
| * | ||
| * @param requestedRange Optional range specifying the offset and size of results to retrieve. | ||
| * @return db::RangeResults<db::ArtistId> The resulting range of artist IDs, possibly with a flag indicating more results. | ||
| */ | ||
| db::RangeResults<db::ArtistId> ArtistCollector::get(std::optional<db::Range> requestedRange) | ||
| { | ||
| // Obtain references to the feedback and scrobbling services. | ||
| feedback::IFeedbackService& feedbackService{ *core::Service<feedback::IFeedbackService>::get() }; | ||
| @@ -39,2 +50,3 @@ | ||
|
|
||
| // Determine the actual range to use, based on the requested range or defaults. | ||
| const Range range{ getActualRange(requestedRange) }; | ||
| @@ -43,2 +55,3 @@ | ||
|
|
||
| // Select the retrieval strategy based on the current mode. | ||
| switch (getMode()) | ||
| @@ -46,2 +59,3 @@ | ||
| case Mode::Random: | ||
| // Retrieve a random selection of artists within the specified range. | ||
| artists = getRandomArtists(range); | ||
| @@ -51,2 +65,3 @@ | ||
| { | ||
| // Retrieve artists starred by the current user, sorted by the date they were starred (most recent first). | ||
| feedback::IFeedbackService::ArtistFindParameters params; | ||
| @@ -64,2 +79,3 @@ | ||
| { | ||
| // Retrieve artists that the current user has recently played, using the scrobbling service. | ||
| scrobbling::IScrobblingService::ArtistFindParameters params; | ||
| @@ -77,2 +93,3 @@ | ||
| { | ||
| // Retrieve the most played artists for the current user, using the scrobbling service. | ||
| scrobbling::IScrobblingService::ArtistFindParameters params; | ||
| @@ -90,2 +107,3 @@ | ||
| { | ||
| // Retrieve artists that were most recently added to the database. | ||
| db::Artist::FindParameters params; | ||
| @@ -98,2 +116,3 @@ | ||
| { | ||
| // Use a read transaction for database access. | ||
| auto transaction{ LmsApp->getDbSession().createReadTransaction() }; |
| } | ||
| } | ||
|
|
||
| void Release::createTracks(Wt::WContainerWidget* tracksContainer, const db::Medium::pointer& medium, bool displayTrackArtists) |
Check warning
Code scanning / CodeQL
Poorly documented large function Warning
Copilot Autofix
AI 3 months ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
No description provided.