LGTM alerts review

This commit is contained in:
emeric
2020-11-03 11:26:44 +01:00
parent 30b6dc59ec
commit 9a1e730831
9 changed files with 27 additions and 19 deletions
+1 -1
View File
@@ -156,7 +156,7 @@ LMS.mediaplayer = function () {
_elems.volumeslider = document.getElementById("lms-mp-volume-slider"); _elems.volumeslider = document.getElementById("lms-mp-volume-slider");
_elems.transcodingActive = document.getElementById("lms-transcoding-active"); _elems.transcodingActive = document.getElementById("lms-transcoding-active");
$(_elems.transcodingActive).tooltip() $(_elems.transcodingActive).tooltip();
var source = _audioCtx.createMediaElementSource(_elems.audio); var source = _audioCtx.createMediaElementSource(_elems.audio);
source.connect(_gainNode); source.connect(_gainNode);
+2
View File
@@ -17,6 +17,8 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>. * along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once
#include <vector> #include <vector>
#include "cover/IEncodedImage.hpp" #include "cover/IEncodedImage.hpp"
+2 -2
View File
@@ -93,8 +93,8 @@ class Track : public Wt::Dbo::Dbo<Track>
void setScanVersion(std::size_t version) { _scanVersion = version; } void setScanVersion(std::size_t version) { _scanVersion = version; }
void setTrackNumber(int num) { _trackNumber = num; } void setTrackNumber(int num) { _trackNumber = num; }
void setDiscNumber(int num) { _discNumber = num; } void setDiscNumber(int num) { _discNumber = num; }
void setTotalTrack(std::optional<int> totalTrack) { totalTrack ? _totalTrack = *totalTrack : 0; } void setTotalTrack(std::optional<int> totalTrack) { _totalTrack = totalTrack ? *totalTrack : 0; }
void setTotalDisc(std::optional<int> totalDisc) { totalDisc ? _totalDisc = *totalDisc : 0; } void setTotalDisc(std::optional<int> totalDisc) { _totalDisc = totalDisc ? *totalDisc : 0; }
void setDiscSubtitle(const std::string& name) { _discSubtitle = name; } void setDiscSubtitle(const std::string& name) { _discSubtitle = name; }
void setName(const std::string& name) { _name = std::string(name, 0, _maxNameLength); } void setName(const std::string& name) { _name = std::string(name, 0, _maxNameLength); }
void setDuration(std::chrono::milliseconds duration) { _duration = duration; } void setDuration(std::chrono::milliseconds duration) { _duration = duration; }
+2 -2
View File
@@ -280,9 +280,9 @@ TagLibParser::processTag(Track& track, const std::string& tag, const TagLib::Str
std::set<std::string> clusterNames; std::set<std::string> clusterNames;
for (const auto& valueList : values) for (const auto& valueList : values)
{ {
auto values = splitAndTrimString(valueList.to8Bit(true), "/,;"); const auto splittedValues {splitAndTrimString(valueList.to8Bit(true), "/,;")};
for (const auto& value : values) for (const auto& value : splittedValues)
clusterNames.insert(value); clusterNames.insert(value);
} }
@@ -296,8 +296,8 @@ FeaturesClassifier::getSimilarReleases(Database::Session& session, Database::IdT
for (auto it {std::begin(similarReleaseIds)}; it != std::end(similarReleaseIds);) for (auto it {std::begin(similarReleaseIds)}; it != std::end(similarReleaseIds);)
{ {
const Database::IdType releaseId {*it}; const Database::IdType similarReleaseId {*it};
if (!Database::Release::getById(session, releaseId)) if (!Database::Release::getById(session, similarReleaseId))
it = similarReleaseIds.erase(it); it = similarReleaseIds.erase(it);
else else
it++; it++;
@@ -318,8 +318,8 @@ FeaturesClassifier::getSimilarArtists(Database::Session& session, Database::IdTy
for (auto it {std::begin(similarArtistIds)}; it != std::end(similarArtistIds);) for (auto it {std::begin(similarArtistIds)}; it != std::end(similarArtistIds);)
{ {
const Database::IdType artistId {*it}; const Database::IdType similarArtistId {*it};
if (!Database::Release::getById(session, artistId)) if (!Database::Release::getById(session, similarArtistId))
it = similarArtistIds.erase(it); it = similarArtistIds.erase(it);
else else
it++; it++;
+3 -1
View File
@@ -19,6 +19,7 @@
#include "MediaScanner.hpp" #include "MediaScanner.hpp"
#include <ctime>
#include <boost/asio/placeholders.hpp> #include <boost/asio/placeholders.hpp>
#include <Wt/WLocalDateTime.h> #include <Wt/WLocalDateTime.h>
@@ -458,8 +459,9 @@ MediaScanner::scheduleScan(bool force, const Wt::WDateTime& dateTime)
{ {
std::chrono::system_clock::time_point timePoint {dateTime.toTimePoint()}; std::chrono::system_clock::time_point timePoint {dateTime.toTimePoint()};
std::time_t t {std::chrono::system_clock::to_time_t(timePoint)}; std::time_t t {std::chrono::system_clock::to_time_t(timePoint)};
char ctimeStr[26];
LMS_LOG(DBUPDATER, INFO) << "Scheduling next scan at " << std::string(std::ctime(&t)); LMS_LOG(DBUPDATER, INFO) << "Scheduling next scan at " << std::string(::ctime_r(&t, ctimeStr));
_scheduleTimer.expires_at(timePoint); _scheduleTimer.expires_at(timePoint);
_scheduleTimer.async_wait(cb); _scheduleTimer.async_wait(cb);
} }
+8 -8
View File
@@ -57,23 +57,23 @@ class Matrix
Matrix() = default; Matrix() = default;
Matrix(Coordinate width, Coordinate height) Matrix(Coordinate width, Coordinate height)
: _width{width}, : _width {width}
_height{height} , _height {height}
{ {
_values.resize(_width*_height); _values.resize(static_cast<std::size_t>(_width) * static_cast<std::size_t>(_height));
} }
template<typename... CtArgs> template<typename... CtArgs>
Matrix(Coordinate width, Coordinate height, CtArgs... args) Matrix(Coordinate width, Coordinate height, CtArgs... args)
: _width{width}, : _width {width}
_height{height} , _height {height}
{ {
_values.resize(_width*_height, T{args...}); _values.resize(static_cast<std::size_t>(_width) * static_cast<std::size_t>(_height), T{args...});
} }
void clear() void clear()
{ {
std::vector<T> values(_width*_height); std::vector<T> values(static_cast<std::size_t>(_width) * static_cast<std::size_t>(_height));
_values.swap(values); _values.swap(values);
} }
@@ -112,7 +112,7 @@ class Matrix
Coordinate _width {}; Coordinate _width {};
Coordinate _height {}; Coordinate _height {};
std::vector<T> _values; std::vector<T> _values;
}; };
} // ns SOM } // ns SOM
+3 -1
View File
@@ -19,6 +19,7 @@
#include "subsonic/SubsonicResource.hpp" #include "subsonic/SubsonicResource.hpp"
#include <atomic> #include <atomic>
#include <ctime>
#include <iomanip> #include <iomanip>
#include <unordered_map> #include <unordered_map>
@@ -385,7 +386,8 @@ releaseToResponseNode(const Release::pointer& release, Session& dbSession, const
{ {
std::time_t t {release->getLastWritten().toTime_t()}; std::time_t t {release->getLastWritten().toTime_t()};
std::ostringstream oss; oss << std::put_time(std::gmtime(&t), "%FT%T"); std::tm gmTime;
std::ostringstream oss; oss << std::put_time(::gmtime_r(&t, &gmTime), "%FT%T");
albumNode.setAttribute("created", oss.str()); albumNode.setAttribute("created", oss.str());
} }
@@ -17,6 +17,8 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>. * along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once
#include <boost/asio/ip/address.hpp> #include <boost/asio/ip/address.hpp>
namespace std namespace std