Define a constant instead of duplicating this literal "application/msword" 3 times. Open
'doc' => 'application/msword',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "application/vnd.ms-powerpoint" 4 times. Open
'ppt' => 'application/vnd.ms-powerpoint',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "application/postscript" 3 times. Open
'ai' => 'application/postscript',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "image/jpeg" 3 times. Open
'jpg' => 'image/jpeg',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "application/vnd.ms-excel" 7 times. Open
'xls' => 'application/vnd.ms-excel',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Spaces must be used to indent lines; tabs are not allowed Open
'js' => 'application/javascript',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'jpg' => 'image/jpeg',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'exe' => 'application/x-msdownload',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ppt' => 'application/vnd.ms-powerpoint',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'pps' => 'application/vnd.ms-powerpoint',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'dotm' => 'application/vnd.ms-word.template.macroEnabled.12',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ics' => 'text/calendar',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'swf' => 'application/x-shockwave-flash',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// images
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'xlm' => 'application/vnd.ms-excel',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'html' => 'text/html',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// archives
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// ms office
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'odt' => 'application/vnd.oasis.opendocument.text',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//other
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'xla' => 'application/vnd.ms-excel',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'otp' => 'application/vnd.oasis.opendocument.presentation-template',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'odc' => 'application/vnd.oasis.opendocument.chart',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'otf' => 'application/vnd.oasis.opendocument.formula-template',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'odg' => 'application/vnd.oasis.opendocument.graphics',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'odp' => 'application/vnd.oasis.opendocument.presentation',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'docm' => 'application/vnd.ms-word.document.macroEnabled.12',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'dwg' => 'application/acad',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'mov' => 'video/quicktime',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ps' => 'application/postscript',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'xls' => 'application/vnd.ms-excel',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ppt' => 'application/vnd.ms-powerpoint',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ico' => 'image/vnd.microsoft.icon',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// adobe
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'psd' => 'image/vnd.adobe.photoshop',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'odi' => 'application/vnd.oasis.opendocument.image',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'odt' => 'application/vnd.oasis.opendocument.text',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'tiff' => 'image/tiff',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'zip' => 'application/zip',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'cab' => 'application/vnd.ms-cab-compressed',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'doc' => 'application/msword',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'xls' => 'application/vnd.ms-excel',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'pdf' => 'application/pdf',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
's7z' => 'application/x-7z-compressed',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'xml' => 'application/xml',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'tif' => 'image/tiff',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// audio/video
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'pot' => 'application/vnd.ms-powerpoint',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'odf' => 'application/vnd.oasis.opendocument.formula',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'bmp' => 'image/bmp',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'rtf' => 'application/rtf',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// open office
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'otc' => 'application/vnd.oasis.opendocument.chart-template',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'rar' => 'application/x-rar-compressed',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'htm' => 'text/html',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'flv' => 'video/x-flv',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'jpeg' => 'image/jpeg',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'svg' => 'image/svg+xml',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'otm' => 'application/vnd.oasis.opendocument.text-master',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'txt' => 'text/plain',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'php' => 'text/php',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'gif' => 'image/gif',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'mp3' => 'audio/mpeg',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ott' => 'application/vnd.oasis.opendocument.text-template',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'7z' => 'application/x-7z-compressed',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'csv' => 'text/plain',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'svgz' => 'image/svg+xml',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'xlt' => 'application/vnd.ms-excel',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'dot' => 'application/msword',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'xps' => 'application/vnd.ms-xpsdocument',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'png' => 'image/png',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'rar' => 'application/x-rar-compressed',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'qt' => 'video/quicktime',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ai' => 'application/postscript',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'xlc' => 'application/vnd.ms-excel',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'doc' => 'application/msword',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'css' => 'text/css',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'json' => 'application/json',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'msi' => 'application/x-msdownload',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'otg' => 'application/vnd.oasis.opendocument.graphics-template',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'jpe' => 'image/jpeg',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'pdf' => 'application/pdf',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'oti' => 'application/vnd.oasis.opendocument.image-template',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'eps' => 'application/postscript',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'xlw' => 'application/vnd.ms-excel',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'oth' => 'application/vnd.oasis.opendocument.text-web',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vcf' => 'text/vcard',
- Exclude checks