RegExp lints fix
This commit is contained in:
parent
660b7d784d
commit
beffe11190
|
@ -24,11 +24,11 @@ class EncryptedPrefsFormat @Inject constructor(
|
|||
|
||||
companion object {
|
||||
|
||||
val FORMAT_KEY_ENC = "aaps_encrypted"
|
||||
val FORMAT_KEY_NOENC = "aaps_structured"
|
||||
const val FORMAT_KEY_ENC = "aaps_encrypted"
|
||||
const val FORMAT_KEY_NOENC = "aaps_structured"
|
||||
|
||||
private val KEY_CONSCIENCE = "if you remove/change this, please make sure you know the consequences!"
|
||||
private val FORMAT_TEST_REGEX = Regex("(\\\"format\\\"\\s*\\:\\s*\\\"aaps_[^\"]*\\\")")
|
||||
private const val KEY_CONSCIENCE = "if you remove/change this, please make sure you know the consequences!"
|
||||
private val FORMAT_TEST_REGEX = Regex("(\"format\"\\s*:\\s*\"aaps_[^\"]*\")")
|
||||
}
|
||||
|
||||
override fun isPreferencesFile(file: File, preloadedContents: String?): Boolean {
|
||||
|
@ -94,7 +94,7 @@ class EncryptedPrefsFormat @Inject constructor(
|
|||
var fileContents = container.toString(2)
|
||||
val fileHash = cryptoUtil.hmac256(fileContents, KEY_CONSCIENCE)
|
||||
|
||||
fileContents = fileContents.replace(Regex("(\\\"file_hash\\\"\\s*\\:\\s*\\\")(--to-be-calculated--)(\\\")"), "$1" + fileHash + "$3")
|
||||
fileContents = fileContents.replace(Regex("(\"file_hash\"\\s*:\\s*\")(--to-be-calculated--)(\")"), "$1$fileHash$3")
|
||||
|
||||
storage.putFileContents(file, fileContents)
|
||||
|
||||
|
@ -112,7 +112,7 @@ class EncryptedPrefsFormat @Inject constructor(
|
|||
try {
|
||||
|
||||
val jsonBody = storage.getFileContents(file)
|
||||
val fileContents = jsonBody.replace(Regex("(?is)(\\\"file_hash\\\"\\s*\\:\\s*\\\")([^\"]*)(\\\")"), "$1--to-be-calculated--$3")
|
||||
val fileContents = jsonBody.replace(Regex("(?is)(\"file_hash\"\\s*:\\s*\")([^\"]*)(\")"), "$1--to-be-calculated--$3")
|
||||
val calculatedFileHash = cryptoUtil.hmac256(fileContents, KEY_CONSCIENCE)
|
||||
val container = JSONObject(jsonBody)
|
||||
val metadata: MutableMap<PrefsMetadataKey, PrefMetadata> = loadMetadata(container)
|
||||
|
@ -192,7 +192,7 @@ class EncryptedPrefsFormat @Inject constructor(
|
|||
|
||||
if (decryptedOk && contentJsonObj != null) {
|
||||
for (key in contentJsonObj.keys()) {
|
||||
entries.put(key, contentJsonObj[key].toString())
|
||||
entries[key] = contentJsonObj[key].toString()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ class EncryptedPrefsFormat @Inject constructor(
|
|||
} catch (e: IOException) {
|
||||
throw PrefIOError(file.absolutePath)
|
||||
} catch (e: JSONException) {
|
||||
throw PrefFormatError("Mallformed preferences JSON file: " + e)
|
||||
throw PrefFormatError("Mallformed preferences JSON file: $e")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
|||
public boolean verifyConfiguration(boolean forceRileyLinkAddressRenewal) {
|
||||
try {
|
||||
String regexSN = "[0-9]{6}";
|
||||
String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
|
||||
String regexMac = "([\\da-fA-F]{1,2}(?::|$)){6}";
|
||||
|
||||
medtronicPumpStatus.errorDescription = "-";
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.eros.util.AapsOmnipodUtil
|
|||
*/
|
||||
public class RileyLinkOmnipodService extends RileyLinkService {
|
||||
|
||||
private static final String REGEX_MAC = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
|
||||
private static final String REGEX_MAC = "([\\da-fA-F]{1,2}(?::|$)){6}";
|
||||
|
||||
@Inject OmnipodErosPumpPlugin omnipodErosPumpPlugin;
|
||||
@Inject AapsOmnipodUtil aapsOmnipodUtil;
|
||||
|
|
Loading…
Reference in a new issue