Skip to content

Commit 59bb62d

Browse files
authored
Apply suggestions from code review
1 parent e71bf0d commit 59bb62d

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

QRCoder/QRCodeGenerator.ModulePlacer.MaskPattern.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@ public static int Score(QRCodeData qrCode)
151151
if (qrCode.ModuleMatrix[y][x] == qrCode.ModuleMatrix[y][x + 1] &&
152152
qrCode.ModuleMatrix[y][x] == qrCode.ModuleMatrix[y + 1][x] &&
153153
qrCode.ModuleMatrix[y][x] == qrCode.ModuleMatrix[y + 1][x + 1])
154-
{
155154
score2 += 3;
156-
}
157155
}
158156
}
159157

QRCoder/QRCodeGenerator.ModulePlacer.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static void AddQuietZone(QRCodeData qrCode)
4343
/// <param name="versionStr">The bit array containing the version information.</param>
4444
public static void PlaceVersion(QRCodeData qrCode, BitArray versionStr)
4545
{
46-
var size = qrCode.ModuleMatrix.Count; // The size of the QR code matrix.
46+
var size = qrCode.ModuleMatrix.Count;
4747

4848
// Loop through each module position intended for version information, placed adjacent to the separators.
4949
for (var x = 0; x < 6; x++)
@@ -214,7 +214,7 @@ public static void PlaceDataWords(QRCodeData qrCode, BitArray data, List<Rectang
214214
if (up)
215215
{
216216
y = size - yMod; // Calculate y for upward direction.
217-
// Place data if within data length, current position is not blocked, and leftward column is in bounds.
217+
// Place data if within data length, current position is not blocked, and leftward column is in bounds.
218218
if (index < count && !IsBlocked(new Rectangle(x, y, 1, 1), blockedModules))
219219
qrCode.ModuleMatrix[y][x] = data[index++];
220220
if (index < count && x > 0 && !IsBlocked(new Rectangle(x - 1, y, 1, 1), blockedModules))
@@ -223,7 +223,7 @@ public static void PlaceDataWords(QRCodeData qrCode, BitArray data, List<Rectang
223223
else
224224
{
225225
y = yMod - 1; // Calculate y for downward direction.
226-
// Similar checks and data placement for the downward direction.
226+
// Similar checks and data placement for the downward direction.
227227
if (index < count && !IsBlocked(new Rectangle(x, y, 1, 1), blockedModules))
228228
qrCode.ModuleMatrix[y][x] = data[index++];
229229
if (index < count && x > 0 && !IsBlocked(new Rectangle(x - 1, y, 1, 1), blockedModules))
@@ -284,7 +284,7 @@ public static void ReserveVersionAreas(int size, int version, List<Rectangle> bl
284284
public static void PlaceDarkModule(QRCodeData qrCode, int version, List<Rectangle> blockedModules)
285285
{
286286
// Place the dark module, which is always required to be black.
287-
qrCode.ModuleMatrix[4 * version + 9][8] = true; // Calculated position for the dark module based on the version
287+
qrCode.ModuleMatrix[4 * version + 9][8] = true;
288288
// Block the dark module area to prevent overwriting during further QR code generation steps.
289289
blockedModules.Add(new Rectangle(8, 4 * version + 9, 1, 1));
290290
}
@@ -296,7 +296,7 @@ public static void PlaceDarkModule(QRCodeData qrCode, int version, List<Rectangl
296296
/// <param name="blockedModules">A list of rectangles representing areas that must not be overwritten. This is updated with the areas occupied by the finder patterns.</param>
297297
public static void PlaceFinderPatterns(QRCodeData qrCode, List<Rectangle> blockedModules)
298298
{
299-
var size = qrCode.ModuleMatrix.Count; // Get the size of the QR code matrix.
299+
var size = qrCode.ModuleMatrix.Count;
300300

301301
// Loop to place three finder patterns in the top-left, top-right, and bottom-left corners of the QR code.
302302
for (var i = 0; i < 3; i++)
@@ -399,9 +399,6 @@ public static void PlaceTimingPatterns(QRCodeData qrCode, List<Rectangle> blocke
399399
/// <summary>
400400
/// Determines if two rectangles intersect with each other.
401401
/// </summary>
402-
/// <param name="r1">The first rectangle.</param>
403-
/// <param name="r2">The second rectangle to check for intersection with the first.</param>
404-
/// <returns>True if the rectangles intersect; otherwise, false.</returns>
405402
private static bool Intersects(Rectangle r1, Rectangle r2)
406403
{
407404
// Check if any part of the rectangles overlap.
@@ -413,16 +410,15 @@ private static bool Intersects(Rectangle r1, Rectangle r2)
413410
/// </summary>
414411
/// <param name="r1">The rectangle to check.</param>
415412
/// <param name="blockedModules">The list of rectangles representing blocked areas.</param>
416-
/// <returns>True if the rectangle is blocked; otherwise, false.</returns>
417413
private static bool IsBlocked(Rectangle r1, List<Rectangle> blockedModules)
418414
{
419415
// Iterate through the list of blocked modules to check for any intersection.
420416
foreach (var blockedMod in blockedModules)
421417
{
422418
if (Intersects(blockedMod, r1))
423-
return true; // Return true if an intersection is found, indicating the area is blocked.
419+
return true;
424420
}
425-
return false; // Return false if no intersections are found, indicating the area is not blocked.
421+
return false;
426422
}
427423
}
428424
}

QRCoder/QRCodeGenerator.Polynom.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public override string ToString()
3535

3636
foreach (var polyItem in this.PolyItems)
3737
{
38-
sb.Append($"a^{polyItem.Coefficient}*x^{polyItem.Exponent} + ");
38+
sb.Append("a^" + polyItem.Coefficient + "*x^" + polyItem.Exponent + " + ");
3939
}
4040

4141
// Remove the trailing " + " if the string builder has added terms
@@ -45,6 +45,5 @@ public override string ToString()
4545
return sb.ToString();
4646
}
4747
}
48-
4948
}
5049
}

0 commit comments

Comments
 (0)