Showing 462 of 1,666 total issues
Function _renderDrawers
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
const _renderDrawers = () => {
return activity.map((revision) => {
const courses = revision.courses.map((course) => {
return (
<li key={`${revision.key}-${course.slug}`}>
Function renderConfirm
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
const renderConfirm = () => {
let buttonContent;
if (submittingNewAdmin) {
buttonContent = (<div className="loading__spinner" />);
} else {
Function fetchAll
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
const fetchAll = async (API_URL, params, continue_str) => {
const allData = [];
let continueToken;
let hasMore = true;
while (hasMore) {
Function groupByAssignmentType
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const groupByAssignmentType = (assignments, user_id) => {
// Unassigned to anyone
const unassignedOptions = { user_id: null, role: ASSIGNED_ROLE };
const unassigned = getFiltered(assignments, unassignedOptions);
Function wiki_courses
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function wiki_courses(state = initialState, action) {
switch (action.type) {
case RECEIVE_WIKI_COURSES: {
return {
...state,
Function SiteNoticeForm
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
const SiteNoticeForm = (props) => {
const [siteNotice, setSiteNotice] = useState();
const dispatch = useDispatch();
const handleChange = (key, value) => {
Function NewsPopoverHandler
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
const NewsPopoverHandler = () => {
// State to track whether the create news popover should be shown or not
const [createNews, setCreateNews] = useState(false);
const dispatch = useDispatch();
Function sortByKey
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const sortByKey = (models, sortKey, previousKey = null, desc = false, absolute = false, refresh = false) => {
const sameKey = sortKey === previousKey;
let newKey;
if (sameKey) {
newKey = null;
Function articleListKeys
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const articleListKeys = (course) => {
const articlesOrItems = ArticleUtils.articlesOrItems(course.home_wiki.project);
return {
rating_num: {
label: I18n.t('articles.rating'),
Function active_courses
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function active_courses(state = initialState, action) {
switch (action.type) {
case RECEIVE_ACTIVE_COURSES:
case RECEIVE_CAMPAIGN_ACTIVE_COURSES: {
return {
Function settings
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const settings = (state = initialState, action) => {
switch (action.type) {
case SET_ADMIN_USERS:
return Object.assign({}, state, { adminUsers: action.data.admins });
case SET_SPECIAL_USERS:
Function fetchPageViews
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const fetchPageViews = (articlesList, wiki, dispatch, getState) => {
const promises = chunk(articlesList, 5).map((articles) => {
const query = pageviewQueryGenerator(map(articles, 'pageid'));
return limit(() => queryUrl(mediawikiApiBase(wiki.language, wiki.project), query))
.then(data => data.query.pages)
Function CampaignAlerts
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const CampaignAlerts = () => {
const [defaultFilters] = useState([
{ value: 'ArticlesForDeletionAlert', label: 'Articles For Deletion' },
{ value: 'DiscretionarySanctionsEditAlert', label: 'Discretionary Sanctions' }
]);
Function _renderNotification
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const _renderNotification = (notification, i) => {
let message;
let className = 'notice';
if (notification.type === 'error') {
message = (
Function _renderNotification
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const _renderNotification = (notification, i) => {
let message;
let className = 'notice';
if (notification.type === 'error') {
message = (
Function enroll
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const enroll = (e) => {
e.preventDefault();
const username = usernameRef.current.value;
if (!username) { return; }
const courseId = course.slug;
Function weekMeetings
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
weekMeetings(course, exceptions) {
const weekEnd = endOfWeek(toDate(course.timeline_end));
let weekStart = startOfWeek(toDate(course.timeline_start));
const firstWeekStart = getDay(toDate(course.timeline_start));
const courseWeeks = differenceInWeeks(weekEnd, weekStart, { roundingMethod: 'round' });
- 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 saveUpdatedAdminCourseNote
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export const saveUpdatedAdminCourseNote = adminCourseNoteDetails => async (dispatch, getState) => {
if ((adminCourseNoteDetails.title.trim().length === 0) || (adminCourseNoteDetails.text.trim().length === 0)) {
return sendNotification(dispatch, 'Error', 'notes.empty_fields');
}
- 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 TrainingModulesViewMode
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const TrainingModulesViewMode = (props) => {
const block = props.block;
const modules = [];
const length = block.training_modules.length;
- 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 NewAccountButton
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const NewAccountButton = ({ course, passcode, currentUser }) => {
const [showModal, setShowModal] = useState(false);
const [disabled, setDisabled] = useState(false);
const [isHovered, setIsHovered] = useState(false);
- 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"