1+ /* eslint-disable @typescript-eslint/no-unsafe-return */
2+ /* eslint-disable @typescript-eslint/no-unsafe-call */
3+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
4+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
5+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
16import Logger , { createLogger , LogLevel , Serializers , Stream } from "bunyan" ;
27import { isArray , isString , merge , omit , mapKeys } from "lodash" ;
38import { SafeRawLogStream } from "utils/logger-utils" ;
@@ -8,7 +13,7 @@ const REPO_URL_REGEX = /^(\/api\/v3)?\/repos\/([^/]+)\/([^/]+)\/(.*)$/;
813
914const maybeRemoveOrgAndRepo = ( url : string ) => {
1015 if ( url . match ( REPO_URL_REGEX ) ) {
11- return url . replace ( REPO_URL_REGEX , ( _ , maybeV3Prefix , org , repo , rest ) => {
16+ return url . replace ( REPO_URL_REGEX , ( _ , maybeV3Prefix : string , org : string , repo : string , rest : string ) => {
1217 return [
1318 maybeV3Prefix ,
1419 "repos" ,
@@ -26,7 +31,7 @@ const COMPARE_URL_REGEX = /^(.*)\/compare\/(.*)\.\.\.(.*)$/;
2631const isCompareUrl = ( url : string ) => url . match ( COMPARE_URL_REGEX ) ;
2732
2833const removeBranchesFromCompareUrl = ( url : string ) =>
29- url . replace ( COMPARE_URL_REGEX , ( _ , prefix , branch1 , branch2 ) => {
34+ url . replace ( COMPARE_URL_REGEX , ( _ , prefix : string , branch1 : string , branch2 : string ) => {
3035 return [
3136 prefix ,
3237 "compare" ,
@@ -40,7 +45,7 @@ const GIT_REF_URL_REGEX = /^(.*)\/git\/ref\/([^/]+)$/;
4045const isGitRefUrl = ( url : string ) => url . match ( GIT_REF_URL_REGEX ) ;
4146
4247const removeGitRefFromUrl = ( url : string ) =>
43- url . replace ( GIT_REF_URL_REGEX , ( _ , prefix : string , gitRef ) =>
48+ url . replace ( GIT_REF_URL_REGEX , ( _ , prefix : string , gitRef : string ) =>
4449 `${ prefix } /git/ref/${ createHashWithSharedSecret ( decodeURIComponent ( gitRef ) ) } `
4550 ) ;
4651
@@ -49,7 +54,7 @@ const USERS_URL_REGEX = /^(\/api\/v3)?\/users\/([^/]+)$/;
4954const isUsersUrl = ( url : string ) => url . match ( USERS_URL_REGEX ) ;
5055
5156const removeUserFromUrl = ( url : string ) =>
52- url . replace ( USERS_URL_REGEX , ( _ , maybeV3Prefix , userName ) =>
57+ url . replace ( USERS_URL_REGEX , ( _ , maybeV3Prefix : string , userName : string ) =>
5358 [
5459 maybeV3Prefix ,
5560 "users" ,
@@ -62,7 +67,7 @@ const REST_DEVINFO_BRANCH_URL_REGEX = /^\/rest\/devinfo\/([^/]+)\/repository\/([
6267const isDevInfoBranchUrl = ( url : string ) => url . match ( REST_DEVINFO_BRANCH_URL_REGEX ) ;
6368
6469const removeBranchFromDevInfoUrl = ( url : string ) =>
65- url . replace ( REST_DEVINFO_BRANCH_URL_REGEX , ( _ , version , repoNo , branchaName , updateSequenceId : string ) =>
70+ url . replace ( REST_DEVINFO_BRANCH_URL_REGEX , ( _ , version : string , repoNo : string , branchaName : string , updateSequenceId : string ) =>
6671 [
6772 "/rest/devinfo" ,
6873 version ,
@@ -85,26 +90,26 @@ const JIRA_HOST_QUERY_PARAM_REGEX = /jiraHost=(https%3A%2F%2F[\w-]+\.atlassian\.
8590
8691const maybeCensorJiraHostInQueryParams = ( url : string ) => {
8792 if ( url . match ( JIRA_HOST_QUERY_PARAM_REGEX ) ) {
88- return url . replace ( JIRA_HOST_QUERY_PARAM_REGEX , ( _ , jiraHostEncoded ) =>
93+ return url . replace ( JIRA_HOST_QUERY_PARAM_REGEX , ( _ , jiraHostEncoded : string ) =>
8994 `jiraHost=${ createHashWithSharedSecret ( decodeURIComponent ( jiraHostEncoded ) ) } ` ) ;
9095 }
9196 return url ;
9297} ;
9398
9499
95100const removeOwnersAndReposFromUrl = ( url : string ) =>
96- url . replace ( CREATE_BRANCH_PAGE_BRANCHES_URL_REGEX , ( _ , prefix , owners , repos , suffix ) =>
101+ url . replace ( CREATE_BRANCH_PAGE_BRANCHES_URL_REGEX , ( _ , prefix : string , owners : string , repos : string , suffix : string ) =>
97102 [
98103 prefix ,
99104 "owners" ,
100105 createHashWithSharedSecret ( decodeURIComponent ( owners ) ) ,
101106 "repos" ,
102107 createHashWithSharedSecret ( decodeURIComponent ( repos ) ) ,
103108 "branches"
104- ] . join ( "/" ) + ( suffix as string )
109+ ] . join ( "/" ) + suffix
105110 ) ;
106111
107- const censorUrl = ( url ) => {
112+ const censorUrl = ( url : string ) : string => {
108113 if ( ! url ) {
109114 return url ;
110115 }
@@ -146,13 +151,13 @@ const censorUrl = (url) => {
146151
147152const MSG_WITH_REPO_NAME_REGEX = / ^ ( .* ) R e p o s i t o r y w i t h t h e n a m e ' ( .* ) \/ ( .* ) ' .$ / ;
148153
149- const censorMessage = ( msg ) => {
154+ const censorMessage = ( msg : string ) : string => {
150155 if ( ! msg ) {
151156 return msg ;
152157 }
153158 if ( typeof msg === "string" ) {
154159 if ( msg . match ( MSG_WITH_REPO_NAME_REGEX ) ) {
155- return msg . replace ( MSG_WITH_REPO_NAME_REGEX , ( _ , prefix , orgName , repoName ) => {
160+ return msg . replace ( MSG_WITH_REPO_NAME_REGEX , ( _ , prefix : string , orgName : string , repoName : string ) => {
156161 return [
157162 prefix ,
158163 "Repository with the name" ,
0 commit comments