         ]
     )
 
+    // swiftlint:disable:next function_body_length
     public func validate(file: File) -> [StyleViolation] {
-        guard let mainTypeSubstructure = mainTypeSubstructure(in: file) else { return [] }
+        guard let mainTypeSubstructure = mainTypeSubstructure(in: file),
+            let mainTypeSubstuctureOffset = mainTypeSubstructure.offset else { return [] }
 
         let extensionsSubstructures = self.extensionsSubstructures(
             in: file,

            mainTypeSubstructure: mainTypeSubstructure
        )

        let mainTypeOffset: [FileTypeOffset] = [(.mainType, mainTypeSubstructure.offset!)]
        let extensionOffsets: [FileTypeOffset] = extensionsSubstructures.map { (.extension, $0.offset!) }
        let supportingTypeOffsets: [FileTypeOffset] = supportingTypesSubstructures.map { (.supportingType, $0.offset!) }

        let orderedFileTypeOffsets = (mainTypeOffset + extensionOffsets + supportingTypeOffsets).sorted { lhs, rhs in
            return lhs.offset < rhs.offset

        supportingTypeKinds.insert(SwiftDeclarationKind.protocol)

        return file.structure.dictionary.substructure.filter { substructure in
            guard let kind = substructure.kind else { return false }
            guard let declarationKind = SwiftDeclarationKind(rawValue: kind) else { return false }
            return substructure.bridge() != mainTypeSubstructure.bridge() &&
                supportingTypeKinds.contains(declarationKind)
        }
