mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Fix Codacy warnings
This commit is contained in:
parent
eaa34c3b7e
commit
3c64fa1e62
|
@ -430,7 +430,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||||
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -92,8 +92,7 @@ public final class HttpHelper {
|
||||||
case XML:
|
case XML:
|
||||||
contentTypes = "application/xml,text/*,*/*";
|
contentTypes = "application/xml,text/*,*/*";
|
||||||
break;
|
break;
|
||||||
case TEXT:
|
default: // Includes TEXT
|
||||||
default:
|
|
||||||
contentTypes = "text/*,*/*";
|
contentTypes = "text/*,*/*";
|
||||||
}
|
}
|
||||||
return downloadViaHttp(uri, contentTypes, maxChars);
|
return downloadViaHttp(uri, contentTypes, maxChars);
|
||||||
|
|
|
@ -173,8 +173,7 @@ public final class CameraManager {
|
||||||
*/
|
*/
|
||||||
public synchronized void setTorch(boolean newSetting) {
|
public synchronized void setTorch(boolean newSetting) {
|
||||||
OpenCamera theCamera = camera;
|
OpenCamera theCamera = camera;
|
||||||
if (theCamera != null) {
|
if (theCamera != null && newSetting != configManager.getTorchState(theCamera.getCamera())) {
|
||||||
if (newSetting != configManager.getTorchState(theCamera.getCamera())) {
|
|
||||||
boolean wasAutoFocusManager = autoFocusManager != null;
|
boolean wasAutoFocusManager = autoFocusManager != null;
|
||||||
if (wasAutoFocusManager) {
|
if (wasAutoFocusManager) {
|
||||||
autoFocusManager.stop();
|
autoFocusManager.stop();
|
||||||
|
@ -187,7 +186,6 @@ public final class CameraManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single preview frame will be returned to the handler supplied. The data will arrive as byte[]
|
* A single preview frame will be returned to the handler supplied. The data will arrive as byte[]
|
||||||
|
|
|
@ -27,12 +27,12 @@ public final class OpenCameraInterface {
|
||||||
|
|
||||||
private static final String TAG = OpenCameraInterface.class.getName();
|
private static final String TAG = OpenCameraInterface.class.getName();
|
||||||
|
|
||||||
private OpenCameraInterface() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/** For {@link #open(int)}, means no preference for which camera to open. */
|
/** For {@link #open(int)}, means no preference for which camera to open. */
|
||||||
public static final int NO_REQUESTED_CAMERA = -1;
|
public static final int NO_REQUESTED_CAMERA = -1;
|
||||||
|
|
||||||
|
private OpenCameraInterface() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the requested camera with {@link Camera#open(int)}, if one exists.
|
* Opens the requested camera with {@link Camera#open(int)}, if one exists.
|
||||||
*
|
*
|
||||||
|
|
|
@ -46,6 +46,11 @@ public abstract class SupplementalInfoRetriever extends AsyncTask<Object,Object,
|
||||||
|
|
||||||
private static final String TAG = "SupplementalInfo";
|
private static final String TAG = "SupplementalInfo";
|
||||||
|
|
||||||
|
private final WeakReference<TextView> textViewRef;
|
||||||
|
private final WeakReference<HistoryManager> historyManagerRef;
|
||||||
|
private final Collection<Spannable> newContents;
|
||||||
|
private final Collection<String[]> newHistories;
|
||||||
|
|
||||||
public static void maybeInvokeRetrieval(TextView textView,
|
public static void maybeInvokeRetrieval(TextView textView,
|
||||||
ParsedResult result,
|
ParsedResult result,
|
||||||
HistoryManager historyManager,
|
HistoryManager historyManager,
|
||||||
|
@ -78,11 +83,6 @@ public abstract class SupplementalInfoRetriever extends AsyncTask<Object,Object,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final WeakReference<TextView> textViewRef;
|
|
||||||
private final WeakReference<HistoryManager> historyManagerRef;
|
|
||||||
private final Collection<Spannable> newContents;
|
|
||||||
private final Collection<String[]> newHistories;
|
|
||||||
|
|
||||||
SupplementalInfoRetriever(TextView textView, HistoryManager historyManager) {
|
SupplementalInfoRetriever(TextView textView, HistoryManager historyManager) {
|
||||||
textViewRef = new WeakReference<>(textView);
|
textViewRef = new WeakReference<>(textView);
|
||||||
historyManagerRef = new WeakReference<>(historyManager);
|
historyManagerRef = new WeakReference<>(historyManager);
|
||||||
|
|
|
@ -59,20 +59,15 @@ public final class StringUtils {
|
||||||
boolean canBeShiftJIS = true;
|
boolean canBeShiftJIS = true;
|
||||||
boolean canBeUTF8 = true;
|
boolean canBeUTF8 = true;
|
||||||
int utf8BytesLeft = 0;
|
int utf8BytesLeft = 0;
|
||||||
//int utf8LowChars = 0;
|
|
||||||
int utf2BytesChars = 0;
|
int utf2BytesChars = 0;
|
||||||
int utf3BytesChars = 0;
|
int utf3BytesChars = 0;
|
||||||
int utf4BytesChars = 0;
|
int utf4BytesChars = 0;
|
||||||
int sjisBytesLeft = 0;
|
int sjisBytesLeft = 0;
|
||||||
//int sjisLowChars = 0;
|
|
||||||
int sjisKatakanaChars = 0;
|
int sjisKatakanaChars = 0;
|
||||||
//int sjisDoubleBytesChars = 0;
|
|
||||||
int sjisCurKatakanaWordLength = 0;
|
int sjisCurKatakanaWordLength = 0;
|
||||||
int sjisCurDoubleBytesWordLength = 0;
|
int sjisCurDoubleBytesWordLength = 0;
|
||||||
int sjisMaxKatakanaWordLength = 0;
|
int sjisMaxKatakanaWordLength = 0;
|
||||||
int sjisMaxDoubleBytesWordLength = 0;
|
int sjisMaxDoubleBytesWordLength = 0;
|
||||||
//int isoLowChars = 0;
|
|
||||||
//int isoHighChars = 0;
|
|
||||||
int isoHighOther = 0;
|
int isoHighOther = 0;
|
||||||
|
|
||||||
boolean utf8bom = bytes.length > 3 &&
|
boolean utf8bom = bytes.length > 3 &&
|
||||||
|
@ -115,24 +110,16 @@ public final class StringUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} //else {
|
}
|
||||||
//utf8LowChars++;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ISO-8859-1 stuff
|
// ISO-8859-1 stuff
|
||||||
if (canBeISO88591) {
|
if (canBeISO88591) {
|
||||||
if (value > 0x7F && value < 0xA0) {
|
if (value > 0x7F && value < 0xA0) {
|
||||||
canBeISO88591 = false;
|
canBeISO88591 = false;
|
||||||
} else if (value > 0x9F) {
|
} else if (value > 0x9F && (value < 0xC0 || value == 0xD7 || value == 0xF7)) {
|
||||||
if (value < 0xC0 || value == 0xD7 || value == 0xF7) {
|
|
||||||
isoHighOther++;
|
isoHighOther++;
|
||||||
} //else {
|
}
|
||||||
//isoHighChars++;
|
|
||||||
//}
|
|
||||||
} //else {
|
|
||||||
//isoLowChars++;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shift_JIS stuff
|
// Shift_JIS stuff
|
||||||
|
|
|
@ -42,11 +42,8 @@ class C40Encoder implements Encoder {
|
||||||
if (!context.hasMoreCharacters()) {
|
if (!context.hasMoreCharacters()) {
|
||||||
//Avoid having a single C40 value in the last triplet
|
//Avoid having a single C40 value in the last triplet
|
||||||
StringBuilder removed = new StringBuilder();
|
StringBuilder removed = new StringBuilder();
|
||||||
if ((buffer.length() % 3) == 2) {
|
if ((buffer.length() % 3) == 2 && (available < 2 || available > 2)) {
|
||||||
if (available < 2 || available > 2) {
|
lastCharSize = backtrackOneCharacter(context, buffer, removed, lastCharSize);
|
||||||
lastCharSize = backtrackOneCharacter(context, buffer, removed,
|
|
||||||
lastCharSize);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
while ((buffer.length() % 3) == 1
|
while ((buffer.length() % 3) == 1
|
||||||
&& ((lastCharSize <= 3 && available != 1) || lastCharSize > 3)) {
|
&& ((lastCharSize <= 3 && available != 1) || lastCharSize > 3)) {
|
||||||
|
|
|
@ -188,11 +188,9 @@ public final class HighLevelEncoder {
|
||||||
int len = context.getCodewordCount();
|
int len = context.getCodewordCount();
|
||||||
context.updateSymbolInfo();
|
context.updateSymbolInfo();
|
||||||
int capacity = context.getSymbolInfo().getDataCapacity();
|
int capacity = context.getSymbolInfo().getDataCapacity();
|
||||||
if (len < capacity) {
|
if (len < capacity && encodingMode != ASCII_ENCODATION && encodingMode != BASE256_ENCODATION) {
|
||||||
if (encodingMode != ASCII_ENCODATION && encodingMode != BASE256_ENCODATION) {
|
|
||||||
context.writeCodeword('\u00fe'); //Unlatch (254)
|
context.writeCodeword('\u00fe'); //Unlatch (254)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//Padding
|
//Padding
|
||||||
StringBuilder codewords = context.getCodewords();
|
StringBuilder codewords = context.getCodewords();
|
||||||
if (codewords.length() < capacity) {
|
if (codewords.length() < capacity) {
|
||||||
|
|
|
@ -63,15 +63,6 @@ public class SymbolInfo {
|
||||||
|
|
||||||
private static SymbolInfo[] symbols = PROD_SYMBOLS;
|
private static SymbolInfo[] symbols = PROD_SYMBOLS;
|
||||||
|
|
||||||
/**
|
|
||||||
* Overrides the symbol info set used by this class. Used for testing purposes.
|
|
||||||
*
|
|
||||||
* @param override the symbol info set to use
|
|
||||||
*/
|
|
||||||
public static void overrideSymbolSet(SymbolInfo[] override) {
|
|
||||||
symbols = override;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final boolean rectangular;
|
private final boolean rectangular;
|
||||||
private final int dataCapacity;
|
private final int dataCapacity;
|
||||||
private final int errorCodewords;
|
private final int errorCodewords;
|
||||||
|
@ -81,6 +72,15 @@ public class SymbolInfo {
|
||||||
private final int rsBlockData;
|
private final int rsBlockData;
|
||||||
private final int rsBlockError;
|
private final int rsBlockError;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overrides the symbol info set used by this class. Used for testing purposes.
|
||||||
|
*
|
||||||
|
* @param override the symbol info set to use
|
||||||
|
*/
|
||||||
|
public static void overrideSymbolSet(SymbolInfo[] override) {
|
||||||
|
symbols = override;
|
||||||
|
}
|
||||||
|
|
||||||
public SymbolInfo(boolean rectangular, int dataCapacity, int errorCodewords,
|
public SymbolInfo(boolean rectangular, int dataCapacity, int errorCodewords,
|
||||||
int matrixWidth, int matrixHeight, int dataRegions) {
|
int matrixWidth, int matrixHeight, int dataRegions) {
|
||||||
this(rectangular, dataCapacity, errorCodewords, matrixWidth, matrixHeight, dataRegions,
|
this(rectangular, dataCapacity, errorCodewords, matrixWidth, matrixHeight, dataRegions,
|
||||||
|
|
|
@ -73,12 +73,8 @@ public final class MultiFormatUPCEANReader extends OneDReader {
|
||||||
// Compute this location once and reuse it on multiple implementations
|
// Compute this location once and reuse it on multiple implementations
|
||||||
int[] startGuardPattern = UPCEANReader.findStartGuardPattern(row);
|
int[] startGuardPattern = UPCEANReader.findStartGuardPattern(row);
|
||||||
for (UPCEANReader reader : readers) {
|
for (UPCEANReader reader : readers) {
|
||||||
Result result;
|
|
||||||
try {
|
try {
|
||||||
result = reader.decodeRow(rowNumber, row, startGuardPattern, hints);
|
Result result = reader.decodeRow(rowNumber, row, startGuardPattern, hints);
|
||||||
} catch (ReaderException ignored) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Special case: a 12-digit code encoded in UPC-A is identical to a "0"
|
// Special case: a 12-digit code encoded in UPC-A is identical to a "0"
|
||||||
// followed by those 12 digits encoded as EAN-13. Each will recognize such a code,
|
// followed by those 12 digits encoded as EAN-13. Each will recognize such a code,
|
||||||
// UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0".
|
// UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0".
|
||||||
|
@ -109,6 +105,9 @@ public final class MultiFormatUPCEANReader extends OneDReader {
|
||||||
return resultUPCA;
|
return resultUPCA;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
} catch (ReaderException ignored) {
|
||||||
|
// continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw NotFoundException.getNotFoundInstance();
|
throw NotFoundException.getNotFoundInstance();
|
||||||
|
|
|
@ -75,14 +75,12 @@ public final class RSS14Reader extends AbstractRSSReader {
|
||||||
for (Pair left : possibleLeftPairs) {
|
for (Pair left : possibleLeftPairs) {
|
||||||
if (left.getCount() > 1) {
|
if (left.getCount() > 1) {
|
||||||
for (Pair right : possibleRightPairs) {
|
for (Pair right : possibleRightPairs) {
|
||||||
if (right.getCount() > 1) {
|
if (right.getCount() > 1 && checkChecksum(left, right)) {
|
||||||
if (checkChecksum(left, right)) {
|
|
||||||
return constructResult(left, right);
|
return constructResult(left, right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
throw NotFoundException.getNotFoundInstance();
|
throw NotFoundException.getNotFoundInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -607,20 +607,15 @@ final class DecodedBitStreamParser {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count % MAX_NUMERIC_CODEWORDS == 0 ||
|
if ((count % MAX_NUMERIC_CODEWORDS == 0 || code == NUMERIC_COMPACTION_MODE_LATCH || end) && count > 0) {
|
||||||
code == NUMERIC_COMPACTION_MODE_LATCH ||
|
|
||||||
end) {
|
|
||||||
// Re-invoking Numeric Compaction mode (by using codeword 902
|
// Re-invoking Numeric Compaction mode (by using codeword 902
|
||||||
// while in Numeric Compaction mode) serves to terminate the
|
// while in Numeric Compaction mode) serves to terminate the
|
||||||
// current Numeric Compaction mode grouping as described in 5.4.4.2,
|
// current Numeric Compaction mode grouping as described in 5.4.4.2,
|
||||||
// and then to start a new one grouping.
|
// and then to start a new one grouping.
|
||||||
if (count > 0) {
|
result.append(decodeBase900toBase10(numericCodewords, count));
|
||||||
String s = decodeBase900toBase10(numericCodewords, count);
|
|
||||||
result.append(s);
|
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return codeIndex;
|
return codeIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,6 @@ import com.google.zxing.qrcode.decoder.Version;
|
||||||
*/
|
*/
|
||||||
final class MatrixUtil {
|
final class MatrixUtil {
|
||||||
|
|
||||||
private MatrixUtil() {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int[][] POSITION_DETECTION_PATTERN = {
|
private static final int[][] POSITION_DETECTION_PATTERN = {
|
||||||
{1, 1, 1, 1, 1, 1, 1},
|
{1, 1, 1, 1, 1, 1, 1},
|
||||||
{1, 0, 0, 0, 0, 0, 1},
|
{1, 0, 0, 0, 0, 0, 1},
|
||||||
|
@ -119,6 +115,10 @@ final class MatrixUtil {
|
||||||
private static final int TYPE_INFO_POLY = 0x537;
|
private static final int TYPE_INFO_POLY = 0x537;
|
||||||
private static final int TYPE_INFO_MASK_PATTERN = 0x5412;
|
private static final int TYPE_INFO_MASK_PATTERN = 0x5412;
|
||||||
|
|
||||||
|
private MatrixUtil() {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
// Set all cells to -1. -1 means that the cell is empty (not set yet).
|
// Set all cells to -1. -1 means that the cell is empty (not set yet).
|
||||||
//
|
//
|
||||||
// JAVAPORT: We shouldn't need to do this at all. The code should be rewritten to begin encoding
|
// JAVAPORT: We shouldn't need to do this at all. The code should be rewritten to begin encoding
|
||||||
|
|
|
@ -45,6 +45,8 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger(AbstractNegativeBlackBoxTestCase.class.getSimpleName());
|
private static final Logger log = Logger.getLogger(AbstractNegativeBlackBoxTestCase.class.getSimpleName());
|
||||||
|
|
||||||
|
private final List<TestResult> testResults;
|
||||||
|
|
||||||
private static final class TestResult {
|
private static final class TestResult {
|
||||||
private final int falsePositivesAllowed;
|
private final int falsePositivesAllowed;
|
||||||
private final float rotation;
|
private final float rotation;
|
||||||
|
@ -54,17 +56,15 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFalsePositivesAllowed() {
|
int getFalsePositivesAllowed() {
|
||||||
return falsePositivesAllowed;
|
return falsePositivesAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getRotation() {
|
float getRotation() {
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final List<TestResult> testResults;
|
|
||||||
|
|
||||||
// Use the multiformat reader to evaluate all decoders in the system.
|
// Use the multiformat reader to evaluate all decoders in the system.
|
||||||
protected AbstractNegativeBlackBoxTestCase(String testBasePathSuffix) {
|
protected AbstractNegativeBlackBoxTestCase(String testBasePathSuffix) {
|
||||||
super(testBasePathSuffix, new MultiFormatReader(), null);
|
super(testBasePathSuffix, new MultiFormatReader(), null);
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class Code128WriterTestCase extends Assert {
|
||||||
private Code128Reader reader;
|
private Code128Reader reader;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setUp() {
|
||||||
writer = new Code128Writer();
|
writer = new Code128Writer();
|
||||||
reader = new Code128Reader();
|
reader = new Code128Reader();
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ public final class MatrixToImageWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* As {@link #writeToFile(BitMatrix, String, File)}, but allows customization of the output.
|
* As {@link #writeToPath(BitMatrix, String, Path)}, but allows customization of the output.
|
||||||
*
|
*
|
||||||
* @param matrix {@link BitMatrix} to write
|
* @param matrix {@link BitMatrix} to write
|
||||||
* @param format image format
|
* @param format image format
|
||||||
|
|
|
@ -56,7 +56,7 @@ public final class MatrixToImageWriterTestCase extends Assert {
|
||||||
matrix.set(0, 1);
|
matrix.set(0, 1);
|
||||||
matrix.set(1, 2);
|
matrix.set(1, 2);
|
||||||
|
|
||||||
BufferedImage newImage = null;
|
BufferedImage newImage;
|
||||||
Path tempFile = Files.createTempFile(null, "." + format);
|
Path tempFile = Files.createTempFile(null, "." + format);
|
||||||
try {
|
try {
|
||||||
MatrixToImageWriter.writeToPath(matrix, format, tempFile, config);
|
MatrixToImageWriter.writeToPath(matrix, format, tempFile, config);
|
||||||
|
|
Loading…
Reference in a new issue