Skip to content

Commit

Permalink
Merge pull request #69 from dfe-analytical-services/add-lintr
Browse files Browse the repository at this point in the history
Added draft lintr script
  • Loading branch information
rmbielby authored Jan 16, 2024
2 parents 3286a11 + 885142a commit b25ed5d
Show file tree
Hide file tree
Showing 14 changed files with 242 additions and 75 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/lintr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '20 3 * * 0'

name: lintr

permissions:
contents: read

jobs:
lintr:
runs-on: ${{ matrix.config.os }}

name: Run lintr scanning

strategy:
fail-fast: false
matrix:
config:
# Running on mac as it's quicker to build
- {os: macOS-latest, r: 'release'}

permissions:
contents: read # for checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup R
uses: r-lib/actions/setup-r@4e1feaf90520ec1215d1882fdddfe3411c08e492
with:
r-version: 4.2.1
use-public-rspm: true

- name: restore renv
uses: r-lib/actions/setup-renv@v2

- name: Install lintr
shell: Rscript {0}
run: |
renv::install("lintr")
- name: Run lintr
run: lintr::sarif_output(lintr::lint_dir("."), "lintr-results.sarif")
shell: Rscript {0}
continue-on-error: true

- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: lintr-results.sarif
wait-for-processing: true
3 changes: 3 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
linters: linters_with_defaults(
object_usage_linter = NULL
)
48 changes: 34 additions & 14 deletions R/dashboard_panels.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,22 @@ homepage_panel <- function() {
class = "panel panel-info",
div(
class = "panel-heading",
style = "color: white;font-size: 18px;font-style: bold; background-color: #1d70b8;",
style = "color: white;font-size: 18px;font-style: bold;
background-color: #1d70b8;",
h2("Contents (h2)")
),
div(
class = "panel-body",
tags$div(
h3("Introduction (h3)"),
p("This app demonstrates the DfE Analytical Services R-Shiny data dashboard template."),
p("You might want to add some brief introductory text here alongside some links to different tabs within your dashboard. Here's an example of a link working:"),
p("This app demonstrates the DfE Analytical Services R-Shiny
data dashboard template."),
p("You might want to add some brief introductory text here
alongside some links to different tabs within your
dashboard. Here's an example of a link working:"),
p(actionLink("link_to_app_content_tab", "Dashboard panel")),
p("You need to add an observeEvent() function to the server.R script for any link that navigates within your App.")
p("You need to add an observeEvent() function to the server.R
script for any link that navigates within your App.")
),
br()
)
Expand All @@ -49,17 +54,26 @@ homepage_panel <- function() {
class = "panel panel-info",
div(
class = "panel-heading",
style = "color: white;font-size: 18px;font-style: bold; background-color: #1d70b8;",
style = "color: white;font-size: 18px;font-style: bold;
background-color: #1d70b8;",
h2("Background Info (h2)")
),
div(
class = "panel-body",
h3("Context and purpose (h3)"),
p("This app is the DfE Analytical Service's R-Shiny template demonstration app and is being developed to provide a coherent styling for DfE dashboards alongside some useful example componenets that teams can adapt for their own uses."),
p("DfE teams using this template should avoid changing the styling and layout, keeping the header, footer and side navigation list formats."),
p("You might want to add some relevant background information for your users here. For example some useful links to your EES publication, data sources and other relevant resources."),
p("This app is the DfE Analytical Service's R-Shiny template
demonstration app and is being developed to provide a coherent
styling for DfE dashboards alongside some useful example
componenets that teams can adapt for their own uses."),
p("DfE teams using this template should avoid changing the
styling and layout, keeping the header, footer and side
navigation list formats."),
p("You might want to add some relevant background information
for your users here. For example some useful links to your EES
publication, data sources and other relevant resources."),
h3("Guidance sources (h3)"),
p("For example, here we'll add some of the key resources we draw on to guide styling and vizualisation...")
p("For example, here we'll add some of the key resources we draw
on to guide styling and vizualisation...")
)
)
)
Expand Down Expand Up @@ -87,7 +101,8 @@ dashboard_panel <- function() {
column(
width = 12,
expandable(
inputId = "details", label = textOutput("dropdown_label"), contents =
inputId = "details", label = textOutput("dropdown_label"),
contents =
div(
id = "div_a",
# class = "well",
Expand All @@ -110,7 +125,8 @@ dashboard_panel <- function() {
),
column(
width = 12,
paste("Download the underlying data for this dashboard:"), br(),
paste("Download the underlying data for this dashboard:"),
br(),
downloadButton(
outputId = "download_data",
label = "Download data",
Expand Down Expand Up @@ -172,16 +188,20 @@ dashboard_panel <- function() {
column(
width = 12,
h2("An example bar chart using ggplot and ggiraph (h2)"),
p("This is the standard paragraph style for adding guiding info around data content."),
p("This is the standard paragraph style for adding guiding
info around data content."),
column(
width = 6,
girafeOutput("colBenchmark", width = "100%", height = "100%")
girafeOutput("colBenchmark",
width = "100%", height = "100%"
)
),
column(
width = 6,
div(
class = "well",
style = "min-height: 100%; height: 100%; overflow-y: visible",
style = "min-height: 100%; height: 100%; overflow-y:
visible",
fluidRow(
column(
width = 12,
Expand Down
6 changes: 5 additions & 1 deletion R/dfe_resources.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@

# message("Sourcing gss colour palette")

suppressMessages(gss_colour_pallette <- afcolours::af_colours("categorical", colour_format = "hex", n = 6))
suppressMessages(
gss_colour_pallette <- afcolours::af_colours("categorical",
colour_format = "hex", n = 6
)
)
15 changes: 12 additions & 3 deletions R/plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ createAvgRevTimeSeries <- function(df, inputArea) {
theme(
text = element_text(size = 12),
axis.title.x = element_text(margin = margin(t = 12)),
axis.title.y = element_text(angle = 0, vjust = 0.5, margin = margin(r = 12)),
axis.title.y = element_text(
angle = 0, vjust = 0.5,
margin = margin(r = 12)
),
axis.line = element_line(size = 0.75),
legend.position = "top"
) +
Expand All @@ -44,14 +47,20 @@ plotAvgRevBenchmark <- function(dfRevenueBalance, inputArea) {
y = average_revenue_balance,
fill = area_name,
id = area_name,
tooltip = paste("<p><b>", area_name, "</b></p>", "<p>£", format(average_revenue_balance, big.mark = ","), "</p>")
tooltip = paste(
"<p><b>", area_name, "</b></p>", "<p>£",
format(average_revenue_balance, big.mark = ","), "</p>"
)
)) +
geom_col_interactive() +
theme_classic() +
theme(
text = element_text(size = 12),
axis.title.x = element_blank(),
axis.title.y = element_text(angle = 0, vjust = 0.5, margin = margin(r = 12)),
axis.title.y = element_text(
angle = 0, vjust = 0.5,
margin = margin(r = 12)
),
axis.line = element_line(size = 0.75),
legend.position = "none"
) +
Expand Down
10 changes: 6 additions & 4 deletions R/read_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
# to either add the file to .gitignore or add an entry for the file into
# datafiles_log.csv.

read_revenue_data <- function(file = "data/la_maintained_schools_revenue_reserve_final.csv") {
# This reads in an example file. For the purposes of this demo, we're using the
# latest LA expenditure data downloaded from the EES release.
read_revenue_data <- function(
file = "data/la_maintained_schools_revenue_reserve_final.csv") {
# This reads in an example file. For the purposes of this demo, we're using
# the latest LA expenditure data downloaded from the EES release.
dfRevenue <- read.csv(file)
# The time period column name has some non-ascii characters so we're just going to rename it here.
# The time period column name has some non-ascii characters so we're just
# going to rename it here.
colnames(dfRevenue)[1] <- "time_period"
dfRevenue <- dfRevenue %>% mutate(
year = as.numeric(paste0("20", substr(format(time_period), 5, 6))),
Expand Down
47 changes: 36 additions & 11 deletions R/standard_panels.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,54 @@ a11y_panel <- function() {
width = 12,
h1("Accessibility statement"),
br("This accessibility statement applies to the **application name**.
This application is run by the Department for Education. We want as many people as possible to be able to use this application,
and have actively developed this application with accessibilty in mind."),
This application is run by the Department for Education. We want as
many people as possible to be able to use this application, and have
actively developed this application with accessibilty in mind."),
h2("WCAG 2.1 compliance"),
br("We follow the reccomendations of the ", a(href = "https://www.w3.org/TR/WCAG21/", "WCAG 2.1 requirements. ", onclick = "ga('send', 'event', 'click', 'link', 'IKnow', 1)"), "This application has been checked using the ", a(href = "https://github.com/ewenme/shinya11y", "Shinya11y tool "), ", which did not detect accessibility issues.
This application also fully passes the accessibility audits checked by the ", a(href = "https://developers.google.com/web/tools/lighthouse", "Google Developer Lighthouse tool"), ". This means that this application:"),
br(
"We follow the reccomendations of the ",
a(
href = "https://www.w3.org/TR/WCAG21/",
"WCAG 2.1 requirements. ",
onclick = "ga('send', 'event', 'click', 'link', 'IKnow', 1)"
),
"This application has been checked using the ",
a(href = "https://github.com/ewenme/shinya11y", "Shinya11y tool "),
", which did not detect accessibility issues.
This application also fully passes the accessibility audits checked
by the ",
a(
href = "https://developers.google.com/web/tools/lighthouse",
"Google Developer Lighthouse tool"
),
". This means that this application:"
),
tags$div(tags$ul(
tags$li("uses colours that have sufficient contrast"),
tags$li("allows you to zoom in up to 300% without the text spilling off the screen"),
tags$li("has its performance regularly monitored, with a team working on any feedback to improve accessibility for all users")
tags$li("allows you to zoom in up to 300% without the text spilling
off the screen"),
tags$li("has its performance regularly monitored, with a team
working on any feedback to improve accessibility for all
users")
)),
h2("Limitations"),
br("We recognise that there are still potential issues with accessibility in this application, but we will continue
to review updates to technology available to us to keep improving accessibility for all of our users. For example, these
are known issues that we will continue to monitor and improve:"),
br("We recognise that there are still potential issues with
accessibility in this application, but we will continue to review
updates to technology available to us to keep improving accessibility
for all of our users. For example, these are known issues that we will
continue to monitor and improve:"),
tags$div(tags$ul(
tags$li("List"),
tags$li("known"),
tags$li("limitations, e.g."),
tags$li("Alternative text in interactive charts is limited to titles and could be more descriptive (although this data is available in csv format)")
tags$li("Alternative text in interactive charts is limited to titles
and could be more descriptive (although this data is
available in csv format)")
)),
h2("Feedback"),
br(
"If you have any feedback on how we could further improve the accessibility of this application, please contact us at",
"If you have any feedback on how we could further improve the
accessibility of this application, please contact us at",
a(href = "mailto:[email protected]", "[email protected]")
)
)
Expand Down
8 changes: 6 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ customDisconnectMessage <- function(refresh = "Refresh page",
},
if (!is.null(publication_name)) {
tags$p(
"All the data used in this dashboard can also be viewed or downloaded via the ",
"All the data used in this dashboard can also be viewed or
downloaded via the ",
tags$a(
href = publication_link,
publication_name
Expand All @@ -53,7 +54,10 @@ customDisconnectMessage <- function(refresh = "Refresh page",
},
tags$p(
"Please contact",
tags$a(href = "mailto:[email protected]", "[email protected]"),
tags$a(
href = "mailto:[email protected]",
"[email protected]"
),
"with details of any problems with this resource."
)
# ),
Expand Down
Loading

0 comments on commit b25ed5d

Please sign in to comment.