Skip to content

Commit

Permalink
Correct code smells
Browse files Browse the repository at this point in the history
Signed-off-by: Le Courtois Florent <[email protected]>
  • Loading branch information
Le Courtois Florent committed Mar 8, 2021
1 parent 0669f35 commit 0145912
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 23 deletions.
6 changes: 3 additions & 3 deletions metrix-simulator/log/src/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ void Logger::logImplDev()
BOOST_LOG_SCOPED_LOGGER_ATTR(
(*logger_),
"Timestamp",
boost::log::attributes::constant<std::chrono::system_clock::time_point>(std::chrono::system_clock::now()));
BOOST_LOG_SCOPED_LOGGER_ATTR((*logger_), "File", boost::log::attributes::constant<std::string>(logInfo_->filename));
BOOST_LOG_SCOPED_LOGGER_ATTR((*logger_), "Line", boost::log::attributes::constant<int>(logInfo_->line));
boost::log::attributes::constant<std::chrono::system_clock::time_point>(std::chrono::system_clock::now()))
BOOST_LOG_SCOPED_LOGGER_ATTR((*logger_), "File", boost::log::attributes::constant<std::string>(logInfo_->filename))
BOOST_LOG_SCOPED_LOGGER_ATTR((*logger_), "Line", boost::log::attributes::constant<int>(logInfo_->line))
BOOST_LOG_SEV((*logger_), logInfo_->level) << logInfo_->stream.str();
}

Expand Down
2 changes: 1 addition & 1 deletion metrix-simulator/src/calcul.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ using std::vector;
// Contrainte : couple quad/incident
//----------------------------------------------------------

#define SITU_N -1
constexpr size_t SITU_N = 1;

class Contrainte
{
Expand Down
15 changes: 7 additions & 8 deletions metrix-simulator/src/calculecrirecontraintesdodu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ int Calculer::ecrireContrainteBilanEnergetique(bool parZonesSynchr)
int nbTermesNonNuls;
double secondMembre;
for (int b = firstZone; b < nbZonesSynch; ++b) {
nbTermesNonNuls = 0, secondMembre = 0.;
nbTermesNonNuls = 0;
secondMembre = 0.;
for (int i = 0; i < pbNombreDeVariables_; ++i) {
if ((typeEtat_[i] == PROD_B) || (typeEtat_[i] == DEPH_H) || (typeEtat_[i] == DEPH_B)
|| (typeEtat_[i] == LIGNE_CC_B)) { // Les autres types de variables n'existent pas encore
Expand Down Expand Up @@ -1217,17 +1218,14 @@ int Calculer::construireJacobienne()
// 1- elimination de la derniere injection
// 2- remplacement de cette derniere par une phase.

int i;
int j;
int k;
int nbQuadN;
int indElmExistDeja = 0;
int nbElmdeMatrContraint = 0;
double elemNod = 0;
bool existDeja;

// construction de la matrice de contraintes d'egalites
for (i = 0; i < res_.nbNoeuds_; ++i) {
for (int i = 0; i < res_.nbNoeuds_; ++i) {
// Attention : Pour l ecriture des contraintes il faut commencer par le traitement des quadripoles
auto& nod = res_.noeuds_[i];
nbQuadN = nod->nbQuads();
Expand All @@ -1244,7 +1242,7 @@ int Calculer::construireJacobienne()
// la derniere injection correspond au noeud bilan
elemNod = 0;
if (!nod->bilan_) {
for (j = 0; j < nbQuadN; ++j) {
for (int j = 0; j < nbQuadN; ++j) {
auto& quad = nod->listeQuads_[j];
auto& nodO = quad->norqua_;
auto& nodE = quad->nexqua_;
Expand All @@ -1256,7 +1254,7 @@ int Calculer::construireJacobienne()
// Noeud voisin = noeuds extremite nodE
auto other_node = (nodO == nod) ? nodE : nodO;
// est que le noeud est deja traite ?
for (k = jacIndexDebutDesColonnes_[i]; k < nbElmdeMatrContraint; ++k) {
for (int k = jacIndexDebutDesColonnes_[i]; k < nbElmdeMatrContraint; ++k) {
if (jacIndicesDeLigne_[k] == static_cast<int>(other_node->num_)) {
existDeja = true;
indElmExistDeja = k;
Expand Down Expand Up @@ -4643,7 +4641,8 @@ void Calculer::printMatriceDesContraintes()
ss << i << ";";
}

indiceDebut = variables.begin(), indiceFin = variables.end();
indiceDebut = variables.begin();
indiceFin = variables.end();

ss << ";B;";

Expand Down
4 changes: 2 additions & 2 deletions metrix-simulator/src/calculmacrofonctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ int Calculer::resolutionProbleme()

// remise du reseau dans son etat initial (toute modification de type production ou conso mais pas les
// lignes indisponibles),
if ((res_.resetReseau(varianteCourante_, (nbCalculs > 0)) != METRIX_PAS_PROBLEME)) {
if (res_.resetReseau(varianteCourante_, (nbCalculs > 0)) != METRIX_PAS_PROBLEME) {
LOG_ALL(error) << "probleme lors de la modification de reseau par la variante numero : "
<< varianteCourante_->num_;
LU_LibererMemoireLU(jacFactorisee_);
Expand Down Expand Up @@ -555,7 +555,7 @@ int Calculer::resolutionUnProblemeDodu(const std::shared_ptr<Variante>& variante

// calcul des coeffs de repport et d'inflencement
//*************************************************
status = calculReportInfluencement();
calculReportInfluencement();

string nomFichier;
FILE* file;
Expand Down
3 changes: 1 addition & 2 deletions metrix-simulator/src/calculrepports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,7 @@ int Calculer::calculeInvB(const std::shared_ptr<Incident>& icdt,

// ATTENTION A verifier ProblemeDeFactorisation; /* Le code retour ( NON_LU si tout s'est bien passe ) */
int codeRet = OUI_LU;
int i;
for (i = 0; i < nbColones; ++i) {
for (int i = 0; i < nbColones; ++i) {
invB[i][i] = 1;
LU_LuSolv(Bptr, &invB[i][0], &codeRet, nullptr, 0, 0.0);
if (codeRet != NON_LU) {
Expand Down
2 changes: 1 addition & 1 deletion metrix-simulator/src/config/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ Configuration::Configuration(const std::string& pathname)
auto raw_config = readRawConfiguration(pathname);
checkConfiguration(raw_config);
initWithRawConfig(raw_config);
} catch (const err::Error& e) {
} catch (const err::Error&) {
// propagate Error without doing anything else
throw;
} catch (const std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion metrix-simulator/src/config/parades_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ ParadesConfiguration::ParadesConfiguration(const std::string& pathname)
} catch (const std::ios_base::failure& e) {
LOG(error) << e.what();
throw ErrorI(err::ioDico().msg("ERRLectFicPointVirgule", pathname));
} catch (const err::Error& err) {
} catch (const err::Error&) {
// do nothing more: propagate error
throw;
} catch (const std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion metrix-simulator/src/config/variant_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ VariantConfiguration::VariantConfiguration(const std::string& pathname) :
} catch (const std::ios_base::failure& e) {
LOG(error) << e.what();
throw ErrorI(err::ioDico().msg("ERRLectFicPointVirgule", pathname));
} catch (const err::Error& err) {
} catch (const err::Error&) {
// do nothing more: propagate error
throw;
} catch (const std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion metrix-simulator/src/reseau.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ bool Groupe::estAjustable(bool adequacy)

void Reseau::update_with_configuration()
{
auto configuration = config::configuration();
const auto& configuration = config::configuration();

coeff_pertes_ = configuration.coeffPertes();
nbRegions_ = configuration.nbRegions();
Expand Down
3 changes: 0 additions & 3 deletions metrix-simulator/src/variante.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,4 @@ struct CompareSet {
}
};

using MapQuadinVar
= std::map<Quadripole::SetQuadripoleSortedByName, std::vector<std::shared_ptr<Variante>>, CompareSet>;

#endif

0 comments on commit 0145912

Please sign in to comment.