-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad word filter Feature (Ready to Use) :D #2940
Conversation
result would be |
@rodrigok it works and I tested it many times bro ;) |
@capensisma this is an automated test o code quality, from https://www.codacy.com/app/RocketChat/Rocket-Chat/pullRequest?prid=220222 |
@engelgabriel there is nothing to be improved there, so ... and it works well and as intended |
CI is good though https://travis-ci.org/RocketChat/Rocket.Chat/builds/124090832 |
It may work well.. this is not the point. The code QUALITY is bad because it doens't follow the standards. |
code QUALITY is bad? okay show me better then! |
What editor do you use? Can you install ESlint? |
I can in the cloud c9.io that's all why is the editor related to this? |
@capensisma a better code syntax looks like: const Filter = Npm.require('bad-words');
RocketChat.callbacks.add('beforeSaveMessage', function(message) {
if (RocketChat.settings.get('Message_AllowBadWordsFilter')) {
const badWordsList = RocketChat.settings.get('Message_BadWordsFilterList');
let filter;
//Add words to the blacklist
if (!!badWordsList && badWordsList.length) {
filter = new Filter({ list: badWordsList.split(',') });
} else {
filter = new Filter();
}
message.msg = filter.clean(message.msg);
}
return message;
}, 1); Your current code is: var Filter = Npm.require('bad-words');
RocketChat.callbacks.add( 'beforeSaveMessage' , function(message){
// console.log(message)
if( RocketChat.settings.get('Message_AllowBadWordsFilter') )
{
var badWordsList = RocketChat.settings.get('Message_BadWordsFilterList');
// console.log(badWordsList)
//Add words to the blacklist
if(!!badWordsList && badWordsList.length)
{
// console.log(badWordsList)
var filter = new Filter({ list: badWordsList.split(',') });
}
else
var filter = new Filter();
message.msg = filter.clean(message.msg);
}
return message;
},1); We have a lot of ESLint rules to keep the code quality, you can use the ESLint command line tool to check your code and you can integrate the ESLint with your code editor to get error hints. |
var filter = new Filter({ list: badWordsList.split(',') }); | ||
} | ||
else | ||
var filter = new Filter(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Expected '{' and instead saw 'var'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Variable 'filter' is already declared in line 16.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: "filter" is already defined
What's the ETA on this? will never be merged or what? bros? |
@capensisma can you take a look at the few code tweaks as included in the previous comment, and the comments on the commit? All are listed here above. We review carefully anything that will directly interact with the messages. We want to make sure to prevent any issues from coming up. Fixing the above mentioned would give us more comfort :) Appreciate the understanding! |
I swear to God there is nothing to change or fix here, its just the codacy doesn't like the indentations or something and it's says |
@capensisma The thing you have to remember about code you contribute. Once you check it in to the project and we accept it, you no longer have to maintain it. We do. Its because of this we are trying to improve code quality. This makes our life easier. But no worries.. I'll take care of this. Thanks for contributing. |
We'll review and merge via #2991 |
Bad Words Filter (Feature)
Here is the bad words filter feature where you can filter all the bad words :
<censored>
Only for test purposes :DTry and enjoy :)