Skip to content
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

opengrok web project code smell fixes #4457

Merged
merged 4 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
public class StatisticsFilter implements Filter {

static final String REQUESTS_METRIC = "requests";
private static final String CATEGORY_TAG = "category";

private final DistributionSummary requests = Metrics.getPrometheusRegistry().summary(REQUESTS_METRIC);

Expand Down Expand Up @@ -76,7 +77,7 @@ private void measure(HttpServletResponse httpResponse, HttpServletRequest httpRe
category = getCategory(httpReq, config);

Timer categoryTimer = Timer.builder("requests.latency").
tags("category", category, "code", String.valueOf(httpResponse.getStatus())).
tags(CATEGORY_TAG, category, "code", String.valueOf(httpResponse.getStatus())).
register(Metrics.getPrometheusRegistry());
categoryTimer.record(duration);

Expand All @@ -85,12 +86,12 @@ private void measure(HttpServletResponse httpResponse, HttpServletRequest httpRe
if (helper != null && registry != null) {
if (helper.getHits() == null || helper.getHits().length == 0) {
Timer.builder("search.latency").
tags("category", "ui", "outcome", "empty").
tags(CATEGORY_TAG, "ui", "outcome", "empty").
register(registry).
record(duration);
} else {
Timer.builder("search.latency").
tags("category", "ui", "outcome", "success").
tags(CATEGORY_TAG, "ui", "outcome", "success").
register(registry).
record(duration);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -74,8 +76,9 @@
public class ProjectsController {

private static final Logger LOGGER = LoggerFactory.getLogger(ProjectsController.class);
private static final String NO_REPO_LOG_MSG = "no repositories found for project ''{0}''";

public static final String PROJECTS_PATH = "/projects";
public static final String PROJECTS_PATH = "projects";

private final RuntimeEnvironment env = RuntimeEnvironment.getInstance();

Expand Down Expand Up @@ -131,19 +134,14 @@ private void addProjectWorkHorse(String projectName) {
List<RepositoryInfo> allrepos = env.getRepositories();
synchronized (allrepos) {
// newly added repository
for (RepositoryInfo repo : repos) {
if (!allrepos.contains(repo)) {
allrepos.add(repo);
}
}
repos.stream()
.filter(repo -> !allrepos.contains(repo))
.forEach(allrepos::add);
// deleted repository
if (map.containsKey(project)) {
for (RepositoryInfo repo : map.get(project)) {
if (!repos.contains(repo)) {
allrepos.remove(repo);
}
}
}
Optional.ofNullable(map.get(project))
.stream().flatMap(Collection::stream)
.filter(repo -> !repos.contains(repo))
.forEach(allrepos::remove);
}

map.put(project, repos);
Expand Down Expand Up @@ -249,7 +247,7 @@ private void deleteProjectDataWorkHorse(Project project, boolean clearHistoryGur

List<RepositoryInfo> repos = env.getProjectRepositoriesMap().get(project);
if (repos == null || repos.isEmpty()) {
LOGGER.log(Level.INFO, "no repositories found for project ''{0}''", projectName);
LOGGER.log(Level.INFO, NO_REPO_LOG_MSG, projectName);
return;
}

Expand All @@ -274,7 +272,7 @@ public Response deleteAnnotationCache(@Context HttpServletRequest request,
Project project = getProjectFromName(projectNameParam);
List<RepositoryInfo> repos = env.getProjectRepositoriesMap().get(project);
if (repos == null || repos.isEmpty()) {
LOGGER.log(Level.INFO, "no repositories found for project ''{0}''", project.getName());
LOGGER.log(Level.INFO, NO_REPO_LOG_MSG, project.getName());
return null;
}

Expand Down Expand Up @@ -307,7 +305,7 @@ public Response deleteHistoryCache(@Context HttpServletRequest request,
Project project = getProjectFromName(projectNameParam);
List<RepositoryInfo> repos = env.getProjectRepositoriesMap().get(project);
if (repos == null || repos.isEmpty()) {
LOGGER.log(Level.INFO, "no repositories found for project ''{0}''", project.getName());
LOGGER.log(Level.INFO, NO_REPO_LOG_MSG, project.getName());
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public void addSearchCountsQueries(final List<String> urls) {
}
}
} catch (MalformedURLException e) {
logger.log(Level.WARNING, "Could not add search counts for " + urlStr, e);
logger.log(Level.WARNING, e, () -> "Could not add search counts for " + urlStr);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public void filter(final ContainerRequestContext context) {
if (!isPathAuthorized(path, request)) {
// TODO: this should probably update statistics for denied requests like in AuthorizationFilter
context.abortWith(Response.status(Response.Status.FORBIDDEN).build());
return; // for good measure
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

.ac_results ul {
width: 100%;
list-style-position: outside;
list-style: none;
list-style-position: outside;
padding: 0;
margin: 0;
}
Expand Down
1 change: 0 additions & 1 deletion opengrok-web/src/main/webapp/default/jquery.combo.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
cursor: pointer;
height: 25px;
width: 22px;
cursor: pointer;
}

.combo_td2 img {
Expand Down
39 changes: 0 additions & 39 deletions opengrok-web/src/main/webapp/default/mandoc-1.0.0.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ table.head { width: 100%;
td.head-vol { text-align: center; }
td.head-rtitle {
text-align: right; }
span.Nd { }

table.foot { width: 100%;
border-top: 1px dotted #808080;
Expand All @@ -85,44 +84,30 @@ h2.Ss { margin-top: 2ex;
margin-left: -2ex;
font-size: 105%; }
div.Pp { margin: 1ex 0ex; }
a.Sx { }
a.Xr { }

/* Displays and lists. */

div.Bd { }
div.D1 { margin-left: 5ex; }

ul.Bl-bullet { list-style-type: disc;
padding-left: 1em; }
li.It-bullet { }
ul.Bl-dash { list-style-type: none;
padding-left: 0em; }
li.It-dash:before {
content: "\2014 "; }
ul.Bl-item { list-style-type: none;
padding-left: 0em; }
li.It-item { }
ul.Bl-compact > li {
margin-top: 0ex; }

ol.Bl-enum { padding-left: 2em; }
li.It-enum { }
ol.Bl-compact > li {
margin-top: 0ex; }

dl.Bl-diag { }
dt.It-diag { }
dd.It-diag { margin-left: 0ex; }
b.It-diag { font-style: normal; }
dl.Bl-hang { }
dt.It-hang { }
dd.It-hang { margin-left: 10.2ex; }
dl.Bl-inset { }
dt.It-inset { }
dd.It-inset { margin-left: 0ex; }
dl.Bl-ohang { }
dt.It-ohang { }
dd.It-ohang { margin-left: 0ex; }
dl.Bl-tag { margin-left: 10.2ex; }
dt.It-tag { float: left;
Expand All @@ -139,41 +124,24 @@ dd.It-tag { clear: right;
dl.Bl-compact > dt {
margin-top: 0ex; }

table.Bl-column { }
tr.It-column { }
td.It-column { margin-top: 1em; }
table.Bl-compact > tbody > tr > td {
margin-top: 0ex; }

cite.Rs { font-style: normal;
font-weight: normal; }
span.RsA { }
i.RsB { font-weight: normal; }
span.RsC { }
span.RsD { }
i.RsI { font-weight: normal; }
i.RsJ { font-weight: normal; }
span.RsN { }
span.RsO { }
span.RsP { }
span.RsQ { }
span.RsR { }
span.RsT { text-decoration: underline; }
a.RsU { }
span.RsV { }

span.eqn { }
table.tbl { }

/* Semantic markup for command line utilities. */

table.Nm { }
b.Nm { font-style: normal; }
b.Fl { font-style: normal; }
b.Cm { font-style: normal; }
var.Ar { font-style: italic;
font-weight: normal; }
span.Op { }
b.Ic { font-style: normal; }
code.Ev { font-style: normal;
font-weight: normal;
Expand All @@ -182,9 +150,7 @@ i.Pa { font-weight: normal; }

/* Semantic markup for function libraries. */

span.Lb { }
b.In { font-style: normal; }
a.In { }
b.Fd { font-style: normal; }
var.Ft { font-style: italic;
font-weight: normal; }
Expand All @@ -204,14 +170,9 @@ code.Er { font-style: normal;

/* Various semantic markup. */

span.An { }
a.Lk { }
a.Mt { }
b.Cd { font-style: normal; }
i.Ad { font-weight: normal; }
b.Ms { font-style: normal; }
span.St { }
a.Ux { }

/* Physical markup. */

Expand Down
8 changes: 0 additions & 8 deletions opengrok-web/src/main/webapp/default/print-1.0.2.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ label {
display: block;
}

#page { }

.error { /* error messages */
color: #a52a2a;
}
Expand Down Expand Up @@ -335,9 +333,6 @@ table#dirlist { /* the "Name" column */


/* file display */
#src {
}

#src pre {
margin: 0;
font-size: small;
Expand Down Expand Up @@ -422,9 +417,6 @@ a.xsr { /* subroutine */ color: #00f; font-weight: bold;
}

/* search result page */
#results {
}

#results p { /* pagetitle and slider */
padding: 0.1em;
}
Expand Down
21 changes: 2 additions & 19 deletions opengrok-web/src/main/webapp/default/style-1.0.4.css
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ button:hover, button:active, .btn:hover, .btn:active {
color: #ffffff;
}

label {
}

.pre { /* the diff content */
white-space: pre-wrap;
font-family: monospace;
Expand All @@ -115,8 +112,6 @@ label {
display: block;
}

#page { }

.error { /* error messages */
color: #a52a2a;
}
Expand Down Expand Up @@ -271,7 +266,6 @@ label {
.version_color_10 { background-color: rgb( 255, 153, 38 ) !important; }

/* ############### start of header ############## */
#whole_header { }

html.xref #whole_header,
html.history #whole_header,
Expand All @@ -285,7 +279,6 @@ html.diff #whole_header {
}

/* *** banner/deco above navbar *** */
#header { }

#MastheadLogo {
width: 171px;
Expand Down Expand Up @@ -368,6 +361,8 @@ html.diff #whole_header {
}

#qtbl {
display: inline-block;
vertical-align: top;
float: left;
width: 35%;
min-width: 300px;
Expand Down Expand Up @@ -736,10 +731,6 @@ span.simplified-path {
color: #888;
}

/* file display */
div[id^='src'] {
}

div[id^='src'] pre {
margin: 0;
}
Expand Down Expand Up @@ -1008,8 +999,6 @@ a.scope { /* scope */ color: steelblue; font-weight: bol
/**** DIFF NAVIGATION/JUMPER *****/

/* search result page */
#results {
}

#results p, #revisions p { /* pagetitle and slider */
padding: 0.1em;
Expand All @@ -1028,9 +1017,6 @@ a.scope { /* scope */ color: steelblue; font-weight: bol
padding-left: 1em;
}

#results .l {
}

#results td.q { /* 1st column: H A D */
white-space: nowrap;
font-size: xx-small;
Expand Down Expand Up @@ -1321,9 +1307,6 @@ h6.message-group-caption {
.clearfix:after {
content: " ";
display: table;
}

.clearfix:after {
clear: both;
}

Expand Down
Loading
Loading