• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / b0d4540074b5fc81a13591dedea4a0d891128cae

15 Jul 2026 03:09PM UTC coverage: 46.297%. First build
b0d4540074b5fc81a13591dedea4a0d891128cae

Pull #23438

github

web-flow
Merge ee6d0d566 into bb528c1d1
Pull Request #23438: feat(bulk-editor): add "needs improvement" filter options to the filters dropdown

4321 of 12255 branches covered (35.26%)

Branch coverage included in aggregate %.

293 of 365 new or added lines in 27 files covered. (80.27%)

30141 of 62182 relevant lines covered (48.47%)

7.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

2.13
/packages/js/src/analysis/refreshAnalysis.js
1
import { doAction } from "@wordpress/hooks";
2
import { actions } from "@yoast/externals/redux";
3
import { Paper } from "yoastseo";
4
import { saveFieldScores } from "./deriveFieldScores";
5
import handleWorkerError from "./handleWorkerError";
6

7
let isInitialized = false;
2✔
8

9
/**
10
 * Sorts analysis results alphabetically by their identifier.
11
 *
12
 * @param {Array} results The SEO or Readability analysis results to be sorted.
13
 *
14
 * @returns {Array} The sorted results.
15
 */
16
export function sortResultsByIdentifier( results ) {
17
        return results.sort( ( a, b ) => a._identifier.localeCompare( b._identifier ) );
×
18
}
19

20
/**
21
 * Refreshes the analysis.
22
 *
23
 * @param {AnalysisWorkerWrapper}               worker        The analysis worker to request the analysis from.
24
 * @param {Function}                            collectData   Function that collects the analysis data.
25
 * @param {Function}                            applyMarks    Function that applies the marks in the content.
26
 * @param {Object}                              store         The store.
27
 * @param {PostDataCollector|TermDataCollector} dataCollector The data collector to update the score of the results.
28
 *
29
 * @returns {void}
30
 */
31
export default function refreshAnalysis( worker, collectData, applyMarks, store, dataCollector ) {
32
        if ( ! isInitialized ) {
×
33
                return;
×
34
        }
35

36
        const paper = Paper.parse( collectData() );
×
37

38
        worker.analyze( paper )
×
39
                .then( results => {
40
                        const { result: { seo, readability, inclusiveLanguage } } = results;
×
41
                        if ( seo ) {
×
42
                                // Only update the main results, which are located under the empty string key.
43
                                const seoResults = seo[ "" ];
×
44

45
                                // Recreate the getMarker function after the worker is done.
46
                                seoResults.results.forEach( result => {
×
47
                                        result.getMarker = () => () => applyMarks( paper, result.marks );
×
48
                                } );
49

50
                                seoResults.results = sortResultsByIdentifier( seoResults.results );
×
51

52
                                store.dispatch( actions.setSeoResultsForKeyword( paper.getKeyword(), seoResults.results ) );
×
53
                                store.dispatch( actions.setOverallSeoScore( seoResults.score, paper.getKeyword() ) );
×
54
                                store.dispatch( actions.refreshSnippetEditor() );
×
55
                                dataCollector.saveScores( seoResults.score, paper.getKeyword() );
×
NEW
56
                                saveFieldScores( seoResults.results );
×
57
                        }
58

59
                        if ( readability ) {
×
60
                                // Recreate the getMarker function after the worker is done.
61
                                readability.results.forEach( result => {
×
62
                                        result.getMarker = () => () => applyMarks( paper, result.marks );
×
63
                                } );
64

65
                                readability.results = sortResultsByIdentifier( readability.results );
×
66
                                store.dispatch( actions.setReadabilityResults( readability.results ) );
×
67
                                store.dispatch( actions.setOverallReadabilityScore( readability.score ) );
×
68
                                store.dispatch( actions.refreshSnippetEditor() );
×
69

70
                                dataCollector.saveContentScore( readability.score );
×
71
                        }
72

73
                        if ( inclusiveLanguage ) {
×
74
                                // Recreate the getMarker function after the worker is done.
75
                                inclusiveLanguage.results.forEach( result => {
×
76
                                        result.getMarker = () => () => applyMarks( paper, result.marks );
×
77
                                } );
78

79
                                inclusiveLanguage.results = sortResultsByIdentifier( inclusiveLanguage.results );
×
80
                                store.dispatch( actions.setInclusiveLanguageResults( inclusiveLanguage.results ) );
×
81
                                store.dispatch( actions.setOverallInclusiveLanguageScore( inclusiveLanguage.score ) );
×
82
                                store.dispatch( actions.refreshSnippetEditor() );
×
83

84
                                dataCollector.saveInclusiveLanguageScore( inclusiveLanguage.score );
×
85
                        }
86

87
                        doAction( "yoast.analysis.refresh", results, { paper, worker, collectData, applyMarks, store, dataCollector } );
×
88
                } )
89
                .catch( handleWorkerError );
90
}
91

92
/**
93
 * Sets isInitialized to true.
94
 *
95
 * @returns {void}
96
 */
97
export function initializationDone() {
98
        isInitialized = true;
×
99
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc