YouTrack InCloud 2017.3 Help

Profanity Blacklist

This workflow blocks the submission of a description or comment if it contains a word from the blacklist.

Name@jetbrains/youtrack-workflow-profanity-blacklist
Previous TitleSpam Blacklist
Auto-attachedno
Modules Block descriptions and comments that contain stop words (on-change rule)
profanity-common.js (custom script)

Use Case

This workflow prevents users from submitting issues or comments that contain offensive language. You can edit the rule to add words to or remove words from the blacklist.

Modules

This workflow contains two modules. The first is an on-change rule that checks the description and comment to see if it contains any word on the blacklist. The second module is a custom script.

Block descriptions and comments that contain stop words

When an issue is reported or updated, this rule checks the description and comment to see if it contains any word on the blacklist. If true, a warning is displayed. The user is informed that the description or comment contains one or more words from the blacklist.

var entities = require('@jetbrains/youtrack-scripting-api/entities'); var workflow = require('@jetbrains/youtrack-scripting-api/workflow'); var profanity = require('./profanity-common'); exports.rule = entities.Issue.onChange({ title: 'Block descriptions and comments that contain stop words', action: function(ctx) { var issue = ctx.issue; var texts = []; function add(text) { if (text) { texts.push(text); } } issue.getAdded('comments').forEach(function(comment) { add(comment.text); }); var becomesReported = issue.becomesReported; if (becomesReported || issue.isChanged('summary')) { add(issue.summary); } if (becomesReported || issue.isChanged('description')) { add(issue.description); } texts.forEach(function(text) { text = text.toLowerCase(); profanity.words.forEach(function(badWord) { var index = text.indexOf(badWord); while (index !== -1) { var sepBefore = index === 0 || profanity.separators.indexOf(text.substring(index - 1, index)) > -1; var endIndex = index + badWord.length; var sepAfter = endIndex === text.length || profanity.separators.indexOf(text.substring(endIndex, endIndex + 1)) > -1; workflow.check(!(sepBefore && sepAfter), workflow.i18n('Prohibited to put the word {0}', badWord)); index = text.indexOf(badWord, endIndex); } }); }); } });

profanity-common.js

This custom script contains all of the words in the stop list. This script is referenced in the on-change rule in the var profanity = require('./profanity-common'); declaration.

If you find any profane words that are reported in your issues or any other words that you want to block, you can update the list of words in this module without modifying the workflow rule.

var workflow = require('@jetbrains/youtrack-scripting-api/workflow'); exports.words = workflow.i18n( '<a comma-separated list of stop words>' ).split(', ').map(function(word) { return word.toLowerCase(); }); exports.separators = '~`!@#$%^&*()-_+=[]{}:;\'\"\\|,<.>/? \n\r\t';
Last modified: 18 August 2017