Skip to content

Commit 9ebd46f

Browse files
author
SReject
committed
Code Qaulity
Fixed: Error in /JSONHttpHeader not following correct format. Improved: Moved `/reseterror` outside of `$error` check. Improved: Fixed: Excessive whitespace in `$JSON` prop deductions. Improved: Removed unused variable in `$jfm_ComInit`. Improved: Removed `%Value` from `$jfm_Create`. Improved: Removed unneeded nested if in `$jfm_GetError`. Change: Increased version to `1.0.1013`.
1 parent 7716963 commit 9ebd46f

1 file changed

Lines changed: 20 additions & 25 deletions

File tree

src/JSON For mIRC.mrc

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ alias JSONHttpMethod {
306306
:error
307307
if ($error) {
308308
%Error = $v1
309-
reseterror
310309
}
310+
reseterror
311311

312312
;; if an error occured, store the error in a global variable then log the error
313313
if (%Error) {
@@ -359,7 +359,7 @@ alias JSONHttpHeader {
359359

360360
;; Validate @name parameter
361361
elseif ($regex($1, /(?:^\d+$)|[*:? ]/i)) {
362-
%Error = Invalid Name
362+
%Error = INVALID_NAME
363363
}
364364
elseif (!$com(JSON: $+ $1)) {
365365
%Error = HANDLE_DOES_NOT_EXIST
@@ -390,8 +390,8 @@ alias JSONHttpHeader {
390390
:error
391391
if ($error) {
392392
%Error = $v1
393-
reseterror
394393
}
394+
reseterror
395395

396396
;; if an error occured, store the error in a global variable then log the error
397397
if (%Error) {
@@ -513,8 +513,8 @@ alias JSONHttpFetch {
513513
:error
514514
if ($error) {
515515
%Error = $error
516-
reseterror
517516
}
517+
reseterror
518518

519519
;; clear the bvar if indicated it should be unset
520520
if (%BUnset) {
@@ -575,7 +575,7 @@ alias JSONClose {
575575
}
576576

577577
;; Validate @Name
578-
elseif (: isin $1 && (w isincs %Switches || JSON:* !iswmcs $1)) {
578+
elseif (: isin $1) && (w isincs %Switches || JSON:* !iswmcs $1) {
579579
%Error = PARAMETER_INVALID
580580
}
581581
else {
@@ -587,7 +587,7 @@ alias JSONClose {
587587
}
588588
%Match = $replacecs(%Match, \E, \E\\E\Q)
589589
if (w isincs $1) {
590-
%Match = $replacecs(%Match, ?, \E[^:]\Q, *,\E[^:]*\Q)
590+
%Match = $replacecs(%Match, ?, \E[^:]\Q, *, \E[^:]*\Q)
591591
}
592592
%Match = /^JSON:\Q $+ %Match $+ \E(?::\d+)*$/i
593593

@@ -617,8 +617,8 @@ alias JSONClose {
617617
:error
618618
if ($error) {
619619
%Error = $error
620-
reseterror
621620
}
621+
reseterror
622622

623623
;; if an error occured, store the error in a global variable then log the error
624624
if (%Error) {
@@ -830,12 +830,12 @@ alias JSON {
830830
}
831831

832832
;; .data has been depreciated; use .input
833-
if (%Prop == data) {
833+
if (%Prop == data) {
834834
%Prop = input
835835
}
836836

837837
;; .isRef has been depreciated; use .isChild
838-
if (%Prop == isRef) {
838+
if (%Prop == isRef) {
839839
%Prop = isChild
840840
}
841841

@@ -1007,13 +1007,13 @@ alias JSON {
10071007
:error
10081008
if ($error) {
10091009
%Error = $error
1010-
reseterror
10111010
}
1011+
reseterror
10121012

10131013
;; If an error occured, store and log the error
10141014
if (%Error) {
10151015
set -u1 %SReject/JSONForMirc/Error %Error
1016-
jfm_log -EeD $!JSON %Error
1016+
jfm_log -EeD %Error
10171017
}
10181018
else {
10191019
jfm_log -EsD %Result
@@ -1178,8 +1178,8 @@ alias JSONForEach {
11781178
:error
11791179
if ($error) {
11801180
%Error = $error
1181-
reseterror
11821181
}
1182+
reseterror
11831183

11841184
;; if an error occured, close the items com if its open, then store and log the error
11851185
if (%Error) {
@@ -1274,8 +1274,8 @@ alias JSONPath {
12741274
:error
12751275
if ($error) {
12761276
%Error = $v1
1277-
reseterror
12781277
}
1278+
reseterror
12791279

12801280
;; If an error occured, store it then log the error
12811281
if (%Error) {
@@ -1307,7 +1307,7 @@ alias JSONError {
13071307
;; Returns the short version
13081308
alias JSONVersion {
13091309
if ($isid) {
1310-
var %Ver = 1.0.1012
1310+
var %Ver = 1.0.1013
13111311
if ($0) {
13121312
return %Ver
13131313
}
@@ -1467,7 +1467,7 @@ alias -l jfm_ComInit {
14671467
if (!$isid) return
14681468

14691469
;; Local variable declaration
1470-
var %Error, %Js = $jfm_tmpbvar, %S = jfm_badd %Js
1470+
var %Error, %Js = $jfm_tmpbvar
14711471

14721472
;; Log the alias call
14731473
jfm_log -I $!jfm_ComInit
@@ -1577,13 +1577,9 @@ alias -l jfm_GetError {
15771577
.comclose $v1
15781578
}
15791579

1580-
;; attempt to retrieve the shell com's last error
1581-
if ($com(SReject/JSONForMirc/JSONShell, Error, 2, dispatch* SReject/JSONForMirc/JSONShellError) && !$comerr && $com(SReject/JSONForMirc/JSONShellError) && $com(SReject/JSONForMirc/JSONShellError, Description, 2) && !$comerr) {
1582-
1583-
;; retrieve the result and store it in %Error
1584-
if ($com(SReject/JSONForMirc/JSONShellError).result) {
1585-
%Error = $v1
1586-
}
1580+
;; attempt to retrieve the shell com's last error and store the result in %Error
1581+
if ($com(SReject/JSONForMirc/JSONShell, Error, 2, dispatch* SReject/JSONForMirc/JSONShellError) && !$comerr && $com(SReject/JSONForMirc/JSONShellError) && $com(SReject/JSONForMirc/JSONShellError, Description, 2) && !$comerr && $com(SReject/JSONForMirc/JSONShellError).result !== $null) {
1582+
%Error = $v1
15871583
}
15881584

15891585
;; close the ShellError com
@@ -1660,18 +1656,17 @@ alias -l jfm_Create {
16601656
alias -l jfm_Exec {
16611657

16621658
;; local variable declaration
1663-
var %Args, %Index = 1, %Value, %Params, %Error
1659+
var %Args, %Index = 1, %Params, %Error
16641660

16651661
;; cleanup from previous call
16661662
unset %SReject/JSONForMirc/Exec
16671663

16681664
;; Loop over inputs, storing them in %Args(for logging), and %Params(for com calling)
16691665
:args
16701666
if (%Index <= $0) {
1671-
%Value = $($ $+ %Index, 2)
16721667
%Args = %Args $+ $iif($len(%Args), $chr(44)) $+ $($ $+ %Index, 2)
16731668
if (%Index >= 3) {
1674-
if ($prop == fromBvar && $regex(%Value, /^& (&\S+)$/)) {
1669+
if ($prop == fromBvar && $regex($($ $+ %Index, 2), /^& (&\S+)$/)) {
16751670
%Params = %Params $+ ,&bstr, $+ $regml(1)
16761671
}
16771672
else {

0 commit comments

Comments
 (0)