brightdigit/OrchardNest

View on GitHub

Showing 13 of 244 total issues

File HTML.swift has 337 lines of code (exceeds 250 allowed). Consider refactoring.
Confirmed

import Foundation
import OrchardNestKit
import Plot
import Vapor

Severity: Minor
Found in Sources/OrchardNestServer/HTML.swift - About 4 hrs to fix

Function li has 99 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static func li(forEntryItem item: EntryItem, formatDateWith formatter: DateFormatter) -> Self {
    return
      .li(
        .class("blog-post"),
        .id("entry-\(item.id.base32Encoded)"),
Severity: Major
Found in Sources/OrchardNestServer/HTML.swift - About 3 hrs to fix

Function playerForPodcast has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static func playerForPodcast(withAppleId appleId: Int) -> Self {
    .ul(
      .class("podcast-players"),
      .li(
        .a(
Severity: Major
Found in Sources/OrchardNestServer/HTML.swift - About 3 hrs to fix

Function configure has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Confirmed

  public func configure(_ app: Application) throws {
    let html = HTMLController(markdownDirectory: app.directory.viewsDirectory)
    app.middleware = .init()
    app.middleware.use(ErrorPageMiddleware(htmlController: html))
    app.middleware.use(FileMiddleware(publicDirectory: app.directory.publicDirectory))
Severity: Major
Found in Sources/OrchardNestServer/Configurator.swift - About 2 hrs to fix

Function header has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Confirmed

  static func header() -> Self {
    .header(
      .class("container"),
      .nav(
        .class("row"),
Severity: Minor
Found in Sources/OrchardNestServer/HTML.swift - About 1 hr to fix

Function respond has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public func respond(to request: Request, chainingTo next: Responder) -> EventLoopFuture<Response> {
    next.respond(to: request).flatMapAlways { result in
      let code: UInt
      let viewName: String
      let html: HTML
Severity: Minor
Found in Sources/OrchardNestServer/ErrorPageMiddleware.swift - About 1 hr to fix

Function head has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Confirmed

  static func head(withSubtitle subtitle: String, andDescription description: String) -> Self {
    return
      .head(
        .title("OrchardNest - \(subtitle)"),
        .meta(.charset(.utf8)),
Severity: Minor
Found in Sources/OrchardNestServer/HTML.swift - About 1 hr to fix

Function footer has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static func footer() -> Self {
    return footer(
      .class("container"),
      .div(
        .class("row"),
Severity: Minor
Found in Sources/OrchardNestServer/HTML.swift - About 1 hr to fix

Function respond has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  public func respond(to request: Request, chainingTo next: Responder) -> EventLoopFuture<Response> {
    next.respond(to: request).flatMapAlways { result in
      let code: UInt
      let viewName: String
      let html: HTML
Severity: Minor
Found in Sources/OrchardNestServer/ErrorPageMiddleware.swift - About 1 hr to fix

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 from has 5 arguments (exceeds 4 allowed). Consider refactoring.
Confirmed

    categorySlug: String,
    languageCode: String,
    channel: FeedChannel,
    langMap: [String: Language],
    catMap: [String: Category]
Severity: Minor
Found in Sources/OrchardNestServer/Models/FeedConfiguration.swift - About 35 mins to fix

Function parseSite has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Confirmed

  static func parseSite(_ site: OrganizedSite, using client: Client, on eventLoop: EventLoop) -> EventLoopFuture<Result<FeedChannel, FeedError>> {
    return client.get(URI(string: site.site.feed_url.absoluteString)).map { (response) -> Data? in
      response.body.map { buffer in
        Data(buffer: buffer)
      }
Severity: Minor
Found in Sources/OrchardNestServer/Models/FeedChannel.swift - About 35 mins to fix

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

Avoid too many return statements within this function.
Open

      return eventLoop.future(newResult)
Severity: Major
Found in Sources/OrchardNestServer/Models/FeedChannel.swift - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return .success(channel)
Severity: Major
Found in Sources/OrchardNestServer/Models/FeedChannel.swift - About 30 mins to fix
Severity
Category
Status
Source
Language