Showing 464 of 1,680 total issues
Function ActiveCourseList
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
const ActiveCourseList = ({ defaultCampaignOnly = true }) => {
const { isLoaded, courses, sort } = useSelector(state => state.active_courses);
const dispatch = useDispatch();
useEffect(() => {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function fetchReferencesAddedFromWiki
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const fetchReferencesAddedFromWiki = async (wiki_url, revisions) => {
const wiki = getWikiObjectFromURL(wiki_url);
if (!isSupportedORESWiki(wiki)) {
// wiki is not supported
return;
Function validateCurrentQuestion
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
validateCurrentQuestion(e) {
e.preventDefault();
const $target = $(e.target);
const $block = $target.parents('.block');
this.$currentBlock = $block;
Function fetchRevisions
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const fetchRevisions = course => async (dispatch, getState) => {
dispatch({ type: REVISIONS_LOADING });
const state = getState();
const users = state.users.users.filter(user => user.role === STUDENT_ROLE);
if (users.length === 0) {
Function users
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function users(state = initialState, action) {
switch (action.type) {
case RECEIVE_USERS: {
// Transform the 'real_name' for users in 'action' into separate 'first_name'
// and 'last_name' properties if 'real_name' is available by using transformUsers.
Function userRoles
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
userRoles(currentUser, users) {
// Role values correspond to the CoursesUsers roles defined
const roles = {};
if (!currentUser) { return roles; }
if (getFiltered(users, { id: currentUser.id, role: STUDENT_ROLE })[0]) {
Function Campaign
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const Campaign = () => {
const dispatch = useDispatch();
const campaign = useSelector(state => state.campaign);
const { campaign_slug } = useParams();
Function handleParentConditionalChange
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
handleParentConditionalChange(value, conditionalGroup, $parent) {
let { currentAnswers } = conditionalGroup;
let conditional;
// let resetQuestions = false;
Function searchForPages
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async searchForPages(wiki, search_term, namespace, map=(el)=>el, depth, limit=10){
let search_query;
if(search_term.split(' ').length > 1){
// if we have multiple words, search for the exact words
search_query = `intitle:${search_term}`;
Function Controls
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const Controls = (props) => {
const {
course, current_user, students, notify, showOverviewFilters, sortSelect
} = props;
Function search_results
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function search_results(state = initialState, action) {
switch (action.type) {
case FETCH_COURSE_SEARCH_RESULTS: {
return {
...state,
Function LanguagePicker
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const LanguagePicker = () => {
const enN = getNativeName('en');
const esN = getNativeName('es');
const frN = getNativeName('fr');
Function processQuestionGroupData
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
processQuestionGroupData(data) {
const _postData = {};
const answerGroup = {};
data.forEach((field) => {
const { name } = field;
Function validations
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function validations(state = initialState, action) {
switch (action.type) {
// This adds a validation, but without marking it 'changed'.
// This means no error message gets added to the queue.
case ADD_VALIDATION: {
Function TemplatesScoping
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const TemplatesScoping = () => {
const templates = useSelector(state => state.scopingMethods.templates.include);
const home_wiki = useSelector(state => state.course.home_wiki);
const [currentWiki, setCurrentWiki] = useState(home_wiki);
return (
Function news
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function news(state = initialState, action) {
switch (action.type) {
case RECEIVE_NEWS_CONTENT_LIST:
return { ...state, news_content_list: action.news_content_list };
case CREATE_NEWS_CONTENT:
Function ConfigureSiteNotice
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const ConfigureSiteNotice = (props) => {
const [isSiteNotice, setIsSiteNotice] = useState();
const dispatch = useDispatch();
const getKey = () => {
Function Expandable
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Expandable = function (Component) {
const wrappedComponent = createReactClass({
displayName: 'Expandable',
statics: {
Function render
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const currentWeek = CourseDateUtils.currentWeekOrder(this.props.timelineStart);
const weekNumberOffset = CourseDateUtils.weeksBeforeTimeline(this.props.course);
const blocks = [];
Function NotificationsBell
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const NotificationsBell = () => {
const [hasOpenTickets, setHasOpenTickets] = useState(false);
const [hasRequestedAccounts, setHasRequestedAccounts] = useState(false);
useEffect(() => {