Commit cdc6d9d3 for tesseract

commit cdc6d9d313f92941814229e72276e58f5bfa7b06
Author: Stefan Weil <sw@weilnetz.de>
Date:   Sun Jun 21 15:15:44 2026 +0200

    Fix Codacy issues (always true / always false)

    Signed-off-by: Stefan Weil <sw@weilnetz.de>

diff --git a/src/ccmain/control.cpp b/src/ccmain/control.cpp
index 2840e173..41320076 100644
--- a/src/ccmain/control.cpp
+++ b/src/ccmain/control.cpp
@@ -244,8 +244,8 @@ bool Tesseract::RecogAllWordsPassN(int pass_n, ETEXT_DESC *monitor, PAGE_RES_IT
       pr_it->forward();
     }
     ASSERT_HOST(pr_it->word() != nullptr);
-    bool make_next_word_fuzzy = false;
 #ifndef DISABLED_LEGACY_ENGINE
+    bool make_next_word_fuzzy = false;
     if (!AnyLSTMLang() && ReassignDiacritics(pass_n, pr_it, &make_next_word_fuzzy)) {
       // Needs to be setup again to see the new outlines in the chopped_word.
       SetupWordPassN(pass_n, word);
@@ -258,9 +258,11 @@ bool Tesseract::RecogAllWordsPassN(int pass_n, ETEXT_DESC *monitor, PAGE_RES_IT
               word->word->best_choice->debug_string().c_str());
     }
     pr_it->forward();
+#ifndef DISABLED_LEGACY_ENGINE
     if (make_next_word_fuzzy && pr_it->word() != nullptr) {
       pr_it->MakeCurrentWordFuzzy();
     }
+#endif // ndef DISABLED_LEGACY_ENGINE
   }
   return true;
 }
diff --git a/src/ccmain/pagesegmain.cpp b/src/ccmain/pagesegmain.cpp
index 835dedf8..bcd62a48 100644
--- a/src/ccmain/pagesegmain.cpp
+++ b/src/ccmain/pagesegmain.cpp
@@ -84,7 +84,7 @@ static Image RemoveEnclosingCircle(Image pixs) {
       min_count = count;
       pixout.destroy();
       pixout = pixt.copy(); // Save the best.
-    } else if (count >= min_count) {
+    } else {
       break; // We have passed by the best.
     }
   }
diff --git a/src/textord/colfind.cpp b/src/textord/colfind.cpp
index 642ae2be..f7f9253d 100644
--- a/src/textord/colfind.cpp
+++ b/src/textord/colfind.cpp
@@ -437,7 +437,7 @@ int ColumnFinder::FindBlocks(PageSegMode pageseg_mode,
         if (!textord_debug_printable) {
           DisplayTabVectors(window);
         }
-        if (window != nullptr && textord_tabfind_show_partitions > 1) {
+        if (textord_tabfind_show_partitions > 1) {
           window->AwaitEvent(SVET_DESTROY);
         }
       }
diff --git a/src/textord/colpartition.cpp b/src/textord/colpartition.cpp
index 87181d0f..509ff096 100644
--- a/src/textord/colpartition.cpp
+++ b/src/textord/colpartition.cpp
@@ -2331,9 +2331,7 @@ void ColPartition::SmoothSpacings(int resolution, int page_height,
     if (neighbourhood[PN_LOWER] == nullptr ||
         (!neighbourhood[PN_UPPER]->SpacingsEqual(*neighbourhood[PN_LOWER],
                                                  resolution) &&
-         (neighbourhood[PN_UPPER] == nullptr ||
-          neighbourhood[PN_LOWER] == nullptr ||
-          !OKSpacingBlip(resolution, median_space, neighbourhood, 0)) &&
+         !OKSpacingBlip(resolution, median_space, neighbourhood, 0) &&
          (neighbourhood[PN_UPPER - 1] == nullptr ||
           neighbourhood[PN_LOWER - 1] == nullptr ||
           !OKSpacingBlip(resolution, median_space, neighbourhood, -1) ||
diff --git a/src/textord/colpartitionset.cpp b/src/textord/colpartitionset.cpp
index a1dc8220..508e72b3 100644
--- a/src/textord/colpartitionset.cpp
+++ b/src/textord/colpartitionset.cpp
@@ -136,13 +136,12 @@ void ColPartitionSet::ImproveColumnCandidate(const WidthCallback &cb,
         int col_box_left = col_part->BoxLeftKey();
         bool tab_width_ok = cb(part->KeyWidth(col_left, part_right));
         bool box_width_ok = cb(part->KeyWidth(col_box_left, part_right));
-        if (tab_width_ok || (!part_width_ok)) {
+        if (tab_width_ok || !part_width_ok) {
           // The tab is leaving the good column metric at least as good as
           // it was before, so use the tab.
           part->CopyLeftTab(*col_part, false);
           part->SetColumnGoodness(cb);
-        } else if (col_box_left < part_left &&
-                   (box_width_ok || !part_width_ok)) {
+        } else if (col_box_left < part_left && box_width_ok) {
           // The box is leaving the good column metric at least as good as
           // it was before, so use the box.
           part->CopyLeftTab(*col_part, true);
diff --git a/src/training/common/errorcounter.cpp b/src/training/common/errorcounter.cpp
index c3dbf070..2262d98c 100644
--- a/src/training/common/errorcounter.cpp
+++ b/src/training/common/errorcounter.cpp
@@ -138,8 +138,8 @@ void ErrorCounter::DebugNewErrors(ShapeClassifier *new_classifier, ShapeClassifi
       // old classifier was correct, check the new one.
       new_classifier->UnicharClassifySample(*mutable_sample, page_pix, 0, INVALID_UNICHAR_ID,
                                             &results);
-      if (correct_id != 0 && new_counter.AccumulateErrors(true, boosting_mode, fontinfo_table,
-                                                          results, mutable_sample)) {
+      if (new_counter.AccumulateErrors(true, boosting_mode, fontinfo_table,
+                                       results, mutable_sample)) {
         tprintf("New Error on sample %d: Classifier debug output:\n", it->GlobalSampleIndex());
         ++total_new_errors;
         new_classifier->UnicharClassifySample(*mutable_sample, page_pix, 1, correct_id, &results);
diff --git a/src/training/unicharset/lstmtrainer.cpp b/src/training/unicharset/lstmtrainer.cpp
index d3a97816..f31e9095 100644
--- a/src/training/unicharset/lstmtrainer.cpp
+++ b/src/training/unicharset/lstmtrainer.cpp
@@ -793,7 +793,7 @@ bool LSTMTrainer::EncodeString(const std::string &str,
                                const UNICHARSET &unicharset,
                                const UnicharCompress *recoder, bool simple_text,
                                int null_char, std::vector<int> *labels) {
-  if (str.c_str() == nullptr || str.length() <= 0) {
+  if (str.empty()) {
     tprintf("Empty truth string!\n");
     return false;
   }
@@ -1134,7 +1134,7 @@ bool LSTMTrainer::DebugLSTMTraining(const NetworkIO &inputs,
                                     const std::vector<int> &truth_labels,
                                     const NetworkIO &outputs) {
   const std::string &truth_text = DecodeLabels(truth_labels);
-  if (truth_text.c_str() == nullptr || truth_text.length() <= 0) {
+  if (truth_text.empty()) {
     tprintf("Empty truth string at decode time!\n");
     return false;
   }