-
Notifications
You must be signed in to change notification settings - Fork 82
Revert "To show Commits in Scrum Report " #131
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
Conversation
Reviewer's GuideThis PR reverts the previous commit that added detailed commit-level fetching and caching by removing complex batch and storage logic, restoring simple jQuery AJAX calls for GitHub issues, PR reviews, and user data, cleaning up debug utilities and variable declarations, and simplifying the report injection and refresh mechanisms. Class diagram for reverted caching and commit-fetching logicclassDiagram
class ScrumHelper {
+allIncluded(outputTarget)
+fetchGithubData()
+writeGithubIssuesPrs()
+writeGithubPrsReviews()
+writeScrumBody()
+scrumSubjectLoaded()
}
%% The following classes and objects were removed in the revert:
class GithubCache {
-data
-cacheKey
-timestamp
-ttl
-fetching
-queue
-errors
-errorTTL
-subject
+saveToStorage()
+loadFromStorage()
+forceGithubDataRefresh()
+verifyCacheStatus()
+debugCache()
}
ScrumHelper ..|> GithubCache : (Removed composition)
%% The reverted code no longer uses GithubCache, and fetchGithubData is now a simple AJAX function.
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @hpdang - I've reviewed your changes and they look great!
Blocking issues:
- User controlled data in methods like
innerHTML
,outerHTML
ordocument.write
is an anti-pattern that can lead to XSS vulnerabilities (link) - User controlled data in a
scrumReport.innerHTML
is an anti-pattern that can lead to XSS vulnerabilities (link)
Prompt for AI Agents
Please address the comments from this code review:
## Security Issues
### Issue 1
<location> `src/scripts/scrumHelper.js:297` </location>
<issue_to_address>
**security (insecure-document-method):** User controlled data in methods like `innerHTML`, `outerHTML` or `document.write` is an anti-pattern that can lead to XSS vulnerabilities
*Source: opengrep*
</issue_to_address>
### Issue 2
<location> `src/scripts/scrumHelper.js:297` </location>
<issue_to_address>
**security (insecure-innerhtml):** User controlled data in a `scrumReport.innerHTML` is an anti-pattern that can lead to XSS vulnerabilities
*Source: opengrep*
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
if (outputTarget === 'popup') { | ||
const scrumReport = document.getElementById('scrumReport'); | ||
if (scrumReport) { | ||
log("found div, updating content"); | ||
console.log("found div, updating content"); | ||
scrumReport.innerHTML = content; |
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.
security (insecure-document-method): User controlled data in methods like innerHTML
, outerHTML
or document.write
is an anti-pattern that can lead to XSS vulnerabilities
Source: opengrep
if (outputTarget === 'popup') { | ||
const scrumReport = document.getElementById('scrumReport'); | ||
if (scrumReport) { | ||
log("found div, updating content"); | ||
console.log("found div, updating content"); | ||
scrumReport.innerHTML = content; |
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.
security (insecure-innerhtml): User controlled data in a scrumReport.innerHTML
is an anti-pattern that can lead to XSS vulnerabilities
Source: opengrep
function handleEnableChange() { | ||
let value = enableToggleElement.checked; | ||
var value = enableToggleElement.checked; |
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 (code-quality): Use const
or let
instead of var
. (avoid-using-var
)
Explanation
`const` is preferred as it ensures you cannot reassign references (which can lead to buggy and confusing code). `let` may be used if you need to reassign references - it's preferred to `var` because it is block- rather than function-scoped.From the Airbnb JavaScript Style Guide
chrome.storage.local.set({ enableToggle: value }); | ||
} | ||
function handleStartingDateChange() { | ||
let value = startingDateElement.value; | ||
var value = startingDateElement.value; |
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 (code-quality): Use const
or let
instead of var
. (avoid-using-var
)
Explanation
`const` is preferred as it ensures you cannot reassign references (which can lead to buggy and confusing code). `let` may be used if you need to reassign references - it's preferred to `var` because it is block- rather than function-scoped.From the Airbnb JavaScript Style Guide
chrome.storage.local.set({ startingDate: value }); | ||
} | ||
function handleEndingDateChange() { | ||
let value = endingDateElement.value; | ||
var value = endingDateElement.value; |
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 (code-quality): Use const
or let
instead of var
. (avoid-using-var
)
Explanation
`const` is preferred as it ensures you cannot reassign references (which can lead to buggy and confusing code). `let` may be used if you need to reassign references - it's preferred to `var` because it is block- rather than function-scoped.From the Airbnb JavaScript Style Guide
var today = new Date(); | ||
var Week = new Date(today.getFullYear(), today.getMonth(), today.getDate()); | ||
var WeekMonth = Week.getMonth() + 1; | ||
var WeekDay = Week.getDate(); |
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 (code-quality): Use const
or let
instead of var
. (avoid-using-var
)
Explanation
`const` is preferred as it ensures you cannot reassign references (which can lead to buggy and confusing code). `let` may be used if you need to reassign references - it's preferred to `var` because it is block- rather than function-scoped.From the Airbnb JavaScript Style Guide
var Week = new Date(today.getFullYear(), today.getMonth(), today.getDate()); | ||
var WeekMonth = Week.getMonth() + 1; | ||
var WeekDay = Week.getDate(); | ||
var WeekYear = Week.getFullYear(); |
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 (code-quality): Use const
or let
instead of var
. (avoid-using-var
)
Explanation
`const` is preferred as it ensures you cannot reassign references (which can lead to buggy and confusing code). `let` may be used if you need to reassign references - it's preferred to `var` because it is block- rather than function-scoped.From the Airbnb JavaScript Style Guide
key: oldCacheKey, | ||
hasData: !!githubCache.data, | ||
timestamp: githubCache.timestamp | ||
// PR reviews fetch | ||
var prUrl = 'https://api.github.com/search/issues?q=commenter%3A' + | ||
githubUsername + | ||
'+org%3Afossasia+updated%3A' + | ||
startingDate + | ||
'..' + | ||
endingDate + | ||
'&per_page=100'; | ||
|
||
$.ajax({ | ||
dataType: 'json', | ||
type: 'GET', | ||
url: prUrl, | ||
error: (xhr, textStatus, errorThrown) => { | ||
console.error('Error fetching PR reviews:', { | ||
status: xhr.status, | ||
textStatus: textStatus, | ||
error: errorThrown | ||
}); | ||
}, | ||
success: (data) => { | ||
githubPrsReviewData = data; | ||
writeGithubPrsReviews(); | ||
}, | ||
}); | ||
|
||
githubCache = { | ||
data: null, | ||
cacheKey: oldCacheKey, | ||
timestamp: 0, | ||
ttl: 5 * 60 * 1000, | ||
fetching: false, | ||
queue: [], | ||
errors: {}, | ||
errorTTL: 60 * 1000, | ||
subject: null | ||
}; | ||
|
||
log('Cache reset complete'); | ||
|
||
await new Promise(resolve => { | ||
chrome.storage.local.remove('githubCache', () => { | ||
log('Storage cache cleared'); | ||
resolve(); | ||
}); | ||
// fetch github user data | ||
var userUrl = 'https://api.github.com/users/' + githubUsername; | ||
$.ajax({ | ||
dataType: 'json', | ||
type: 'GET', | ||
url: userUrl, | ||
error: (xhr, textStatus, errorThrown) => { | ||
// error | ||
}, | ||
success: (data) => { | ||
githubUserData = data; | ||
}, | ||
}); | ||
|
||
try { | ||
log('Starting fresh data fetch...'); | ||
await fetchGithubData(); | ||
log('Force refresh completed successfully'); | ||
return { success: true, timestamp: Date.now() }; | ||
} catch (err) { | ||
logError('Force refresh failed:', err); | ||
throw err; | ||
} | ||
} | ||
|
||
function processGithubData(data) { | ||
githubIssuesData = data.githubIssuesData; | ||
githubPrsReviewData = data.githubPrsReviewData; | ||
githubUserData = data.githubUserData; | ||
prCommitsData = data.prCommitsData || {}; | ||
|
||
if (DEBUG) { | ||
const commitCount = Object.values(prCommitsData) | ||
.reduce((total, prs) => total + prs.reduce((count, pr) => count + pr.commits.length, 0), 0); | ||
|
||
log('Data processed:', { | ||
issues: githubIssuesData?.items?.length || 0, | ||
prs: githubPrsReviewData?.items?.length || 0, | ||
commits: commitCount | ||
}); | ||
} | ||
|
||
lastWeekArray = []; | ||
nextWeekArray = []; | ||
reviewedPrsArray = []; | ||
commitsArray = []; | ||
githubPrsReviewDataProccessed = {}; | ||
|
||
if (!githubCache.subject && scrumSubject) { | ||
scrumSubjectLoaded(); | ||
} | ||
} |
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 (code-quality): Avoid function declarations, favouring function assignment expressions, inside blocks. (avoid-function-declarations-in-blocks
)
Explanation
Function declarations may be hoisted in Javascript, but the behaviour is inconsistent between browsers. Hoisting is generally confusing and should be avoided. Rather than using function declarations inside blocks, you should use function expressions, which create functions in-scope.var issueUrl = 'https://api.github.com/search/issues?q=author%3A' + | ||
githubUsername + | ||
'+org%3Afossasia+created%3A' + | ||
startingDate + | ||
'..' + | ||
endingDate + | ||
'&per_page=100'; |
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 (code-quality): Use const
or let
instead of var
. (avoid-using-var
)
Explanation
`const` is preferred as it ensures you cannot reassign references (which can lead to buggy and confusing code). `let` may be used if you need to reassign references - it's preferred to `var` because it is block- rather than function-scoped.From the Airbnb JavaScript Style Guide
var prUrl = 'https://api.github.com/search/issues?q=commenter%3A' + | ||
githubUsername + | ||
'+org%3Afossasia+updated%3A' + | ||
startingDate + | ||
'..' + | ||
endingDate + | ||
'&per_page=100'; |
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 (code-quality): Use const
or let
instead of var
. (avoid-using-var
)
Explanation
`const` is preferred as it ensures you cannot reassign references (which can lead to buggy and confusing code). `let` may be used if you need to reassign references - it's preferred to `var` because it is block- rather than function-scoped.From the Airbnb JavaScript Style Guide
Reverts #114
Standalone generation is not working. Username and other inputs are not being saved.
Summary by Sourcery
Revert previous commit–showing enhancements and restore basic Scrum report generation, fixing broken standalone workflow and input persistence.
Bug Fixes:
Enhancements:
Documentation:
Chores: